mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 01:52:25 -06:00
[chore] bump bun v1.1.14 -> v1.1.15 (#2195)
This commit is contained in:
parent
23dd6f664c
commit
7011f57b09
27 changed files with 273 additions and 90 deletions
22
vendor/github.com/uptrace/bun/extra/bunotel/option.go
generated
vendored
22
vendor/github.com/uptrace/bun/extra/bunotel/option.go
generated
vendored
|
|
@ -2,7 +2,9 @@ package bunotel
|
|||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
type Option func(h *QueryHook)
|
||||
|
|
@ -30,3 +32,23 @@ func WithFormattedQueries(format bool) Option {
|
|||
h.formatQueries = format
|
||||
}
|
||||
}
|
||||
|
||||
// WithTracerProvider returns an Option to use the TracerProvider when
|
||||
// creating a Tracer.
|
||||
func WithTracerProvider(tp trace.TracerProvider) Option {
|
||||
return func(h *QueryHook) {
|
||||
if tp != nil {
|
||||
h.tracer = tp.Tracer("github.com/uptrace/bun")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithMeterProvider returns an Option to use the MeterProvider when
|
||||
// creating a Meter.
|
||||
func WithMeterProvider(mp metric.MeterProvider) Option {
|
||||
return func(h *QueryHook) {
|
||||
if mp != nil {
|
||||
h.meter = mp.Meter("github.com/uptrace/bun")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
33
vendor/github.com/uptrace/bun/extra/bunotel/otel.go
generated
vendored
33
vendor/github.com/uptrace/bun/extra/bunotel/otel.go
generated
vendored
|
|
@ -20,20 +20,12 @@ import (
|
|||
"github.com/uptrace/opentelemetry-go-extra/otelsql"
|
||||
)
|
||||
|
||||
var (
|
||||
tracer = otel.Tracer("github.com/uptrace/bun")
|
||||
meter = otel.Meter("github.com/uptrace/bun")
|
||||
|
||||
queryHistogram, _ = meter.Int64Histogram(
|
||||
"go.sql.query_timing",
|
||||
metric.WithDescription("Timing of processed queries"),
|
||||
metric.WithUnit("milliseconds"),
|
||||
)
|
||||
)
|
||||
|
||||
type QueryHook struct {
|
||||
attrs []attribute.KeyValue
|
||||
formatQueries bool
|
||||
attrs []attribute.KeyValue
|
||||
formatQueries bool
|
||||
tracer trace.Tracer
|
||||
meter metric.Meter
|
||||
queryHistogram metric.Int64Histogram
|
||||
}
|
||||
|
||||
var _ bun.QueryHook = (*QueryHook)(nil)
|
||||
|
|
@ -43,6 +35,17 @@ func NewQueryHook(opts ...Option) *QueryHook {
|
|||
for _, opt := range opts {
|
||||
opt(h)
|
||||
}
|
||||
if h.tracer == nil {
|
||||
h.tracer = otel.Tracer("github.com/uptrace/bun")
|
||||
}
|
||||
if h.meter == nil {
|
||||
h.meter = otel.Meter("github.com/uptrace/bun")
|
||||
}
|
||||
h.queryHistogram, _ = h.meter.Int64Histogram(
|
||||
"go.sql.query_timing",
|
||||
metric.WithDescription("Timing of processed queries"),
|
||||
metric.WithUnit("milliseconds"),
|
||||
)
|
||||
return h
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +60,7 @@ func (h *QueryHook) Init(db *bun.DB) {
|
|||
}
|
||||
|
||||
func (h *QueryHook) BeforeQuery(ctx context.Context, event *bun.QueryEvent) context.Context {
|
||||
ctx, _ = tracer.Start(ctx, "", trace.WithSpanKind(trace.SpanKindClient))
|
||||
ctx, _ = h.tracer.Start(ctx, "", trace.WithSpanKind(trace.SpanKindClient))
|
||||
return ctx
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +78,7 @@ func (h *QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent) {
|
|||
}
|
||||
|
||||
dur := time.Since(event.StartTime)
|
||||
queryHistogram.Record(ctx, dur.Milliseconds(), metric.WithAttributes(labels...))
|
||||
h.queryHistogram.Record(ctx, dur.Milliseconds(), metric.WithAttributes(labels...))
|
||||
|
||||
span := trace.SpanFromContext(ctx)
|
||||
if !span.IsRecording() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue