StartFromContext(ctx context.Context, spanName string, opts ...SpanStartOption) (context.Context, Span) #3356
Replies: 1 comment 2 replies
-
We store the span within the context ( As for the tracer provider (and tracer), it can be set globally: Line 45 in 8423364 And retrieved from the global object. However, changing the API to allow storing a tracer provider in the context would be a violation of the specifications. So it won't happen until that specification is changed. There is nothing preventing you from writing your own package which stores a tracer provider within the context, and allows you to retrieve it though. |
Beta Was this translation helpful? Give feedback.
-
I'm using
logr
in some of my modules and code, and this lets me store the Logger inside the context, and to use it from there.see https://pkg.go.dev/github.com/go-logr/logr#FromContext
and, this feels nice to me.
I'm very curious to know if there's something problematic about using this same idea in open-telemetry - or if not, would a PR for it be accepted?
I'm hoping that adding a
NewContext(ctx, Tracer)
that stores it, and aStartFromContext(ctx...)
that uses it, or a NewNoopTracerProvider would be enough, and interesting, but presumably, there is scope for an additionalFromContext()
that either returns the set Tracer , or returns a NewNoopTracerProvider...Beta Was this translation helpful? Give feedback.
All reactions