Skip to content

Define how integrations should obtain a tracer #585

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

Closed
mauriciovasquezbernal opened this issue Apr 15, 2020 · 3 comments · Fixed by #602
Closed

Define how integrations should obtain a tracer #585

mauriciovasquezbernal opened this issue Apr 15, 2020 · 3 comments · Fixed by #602
Assignees
Labels
discussion Issue or PR that needs/is extended discussion. instrumentation Related to the instrumentation of third party libraries or frameworks

Comments

@mauriciovasquezbernal
Copy link
Member

An instrumented library needs to access a tracer to create spans. Right now we have different ways of providing such tracer to the integration:

  1. Pass the Tracer when enabling the instrumentation (pymongo, mysql, dbapi and other DB integrations probably)

  1. Pass a TracerProvider (requests)

  2. Don't pass anything, the integration will get a tracer using opentelemetry.trace.get_tracer() (Flask and WSGI)

tracer = trace.get_tracer(__name__, __version__)

I think the right approach would be to let it pass an optional TracerProvider, if that's not passed the integration should use trace.get_tracer_provider(). This approach provides flexibility, it allows customization and also has a default working version.

A possible downside of this approach is that the user will have to configure the SDK first, anyway this limitation is already present in all the integrations but Flask / WSGI that are creating a new Tracer for each operation, that in my opinion is not efficient and should be improved.

@mauriciovasquezbernal mauriciovasquezbernal added discussion Issue or PR that needs/is extended discussion. ext instrumentation Related to the instrumentation of third party libraries or frameworks labels Apr 15, 2020
@codeboten
Copy link
Contributor

The idea of an optional TracerProvider makes sense to me, this lets the instrumentation instantiate a tracer with the name/version information.

@toumorokoshi
Copy link
Member

That seems like a good middle ground. Although personally I hope no one has a need to route different trace providers to different integrations, it might be good to allow that flexibility.

A possible downside of this approach is that the user will have to configure the SDK first

I think that's fine. As long as all of our examples illustrate that SDK configuration must happen first, and we have clear errors, I don't imagine this being a problem.

Then again there's a weird middle case where some integrations will work fine since they're instantiating tracers not during the initial instrumentation, but later e.g. after the event loop starts. But either way the standard of expecting SDKs to be configured first sounds very reasonble.

@Oberon00
Copy link
Member

I also think this suggestion is sensible. In any case, providing the Tracer from the outside is bad because the tracer is supposed to have the name and version of the instrumentation, and the instrumentation should best provide this information to the TracerProvider itself.

@mauriciovasquezbernal mauriciovasquezbernal self-assigned this Apr 16, 2020
toumorokoshi pushed a commit that referenced this issue Apr 23, 2020
Standardize the interface that trace providers are specified in integrations, as specified in #585.

Adding a helper to create and return a configured TracerProvider with a the span
processor and the memory exporter

api: Add tracer provider parameter to trace.get_tracer(). This eliminates the need for a helper function and boilerplate code to retrieve the appropriate tracer from a passed tracer_provider.
codeboten pushed a commit to codeboten/opentelemetry-python that referenced this issue Apr 23, 2020
…elemetry#602)

Standardize the interface that trace providers are specified in integrations, as specified in open-telemetry#585.

Adding a helper to create and return a configured TracerProvider with a the span
processor and the memory exporter

api: Add tracer provider parameter to trace.get_tracer(). This eliminates the need for a helper function and boilerplate code to retrieve the appropriate tracer from a passed tracer_provider.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Issue or PR that needs/is extended discussion. instrumentation Related to the instrumentation of third party libraries or frameworks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants