Skip to content
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

Request to improve Instrumentation for ALL #2837

Open
bogdandrutu opened this issue Oct 6, 2022 · 2 comments
Open

Request to improve Instrumentation for ALL #2837

bogdandrutu opened this issue Oct 6, 2022 · 2 comments
Assignees
Labels
area: instrumentation Related to an instrumentation package enhancement New feature or request

Comments

@bogdandrutu
Copy link
Member

bogdandrutu commented Oct 6, 2022

A common pattern in instrumentations is to retrieve a Tracer almost every time a span is created, this is not the pattern we want to encourage, and we should change this ASAP to avoid other copying this pattern.

See some examples:

The person who is going to work on this should find all these patterns and fix.

@bogdandrutu bogdandrutu added enhancement New feature or request area: instrumentation Related to an instrumentation package labels Oct 6, 2022
@Aneurysm9
Copy link
Member

I think there's a third way that should be what we recommend. The net/http instrumentation will use a single Tracer instance if a TracerProvider was provided at configuration time, but otherwise will attempt to extract a TracerProvider from the active span and then fall back to the global TracerProvider if there is no active span. This allows for simplified use in multi-tenant scenarios where multiple TracerProviders may be in use while allowing those without that requirement to ensure only one Tracer is ever constructed.

@bogdandrutu
Copy link
Member Author

If the fallback to global TraceProvider, also we should optimize to not call global.TraceProvider().Get(...) every request. You may actually want to provide a mini library for all the logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: instrumentation Related to an instrumentation package enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants