-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Starting a new span from a context.Context is too laborious #609
Comments
For those with access to the "Honeycomb Pollinators" Slack team, we discussed this topic over the last few days in the "discuss-opentelemetry-beta" channel. |
The intention was to have tracer work like a logger in each component. var (
tr = global.Tracer("example.com/componentA")
)
func DoWork(ctx context.Context) {
ctx, span := tr.Start(ctx, "Some work")
} |
Thank you for the suggestion, @rghetia, and for the follow-on discussion on today's SIG call. I'll try using this pattern and report back here shortly. |
The pattern that @rghetia has been working well for me. Thank you for the advice. For now, I don't see the |
I'm not aware of any current plans, nor am I aware of any reason not to do so. If you'd like to open a new issue with a proposal we can discuss at a future SIG meeting. I'm going to close this issue as it appears to have been addressed. |
After using the opentelemetry-go library for a few days, I find it to be tediously verbose compared to my touchstone: Honeycomb's beeline-go library. My focus is on the task I perform most frequently in my code: starting a new span from a
context.Context
.In opentelemetry-go today, the call sequence looks approximately like either
or
This winds up performing the exact same
context.Context
lookup three times—extract aSpan
to get the currentTracer
, then use thatTracer
to start a newSpan
, which in turn tries to find the currentSpan
in that samecontext.Context
twice (the extra lookup buried inparent.GetSpanContextAndLinks
). The result induces no change to theTracer
in use.By contrast, beeline-go offers the
StartSpan
function. It wraps up that first call sequence above more concisely and more efficiently. It's true that there's no notion of an activeTracer
whose implementation could vary, but in most cases that possibility is not relevant in the application or library code being instrumented. Looking around in opentelemetry-go, I know that there's alsoglobal.Tracer(string)
, which could cut down on the search for the currentTracer
, but that forces a map lookup and risks pulling in the wrongTracer
.Was there ever a function considered for this library like beeline-go's
StartSpan
? For an API that aspires to only publish interfaces, I can see how offering a concrete function like that is an odd duck, but it could live in the SDK.The text was updated successfully, but these errors were encountered: