summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/extra/bunotel/option.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/uptrace/bun/extra/bunotel/option.go')
-rw-r--r--vendor/github.com/uptrace/bun/extra/bunotel/option.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/vendor/github.com/uptrace/bun/extra/bunotel/option.go b/vendor/github.com/uptrace/bun/extra/bunotel/option.go
index dc294ffa5..4c9c90a30 100644
--- a/vendor/github.com/uptrace/bun/extra/bunotel/option.go
+++ b/vendor/github.com/uptrace/bun/extra/bunotel/option.go
@@ -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")
+ }
+ }
+}