You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The opentelemetry.trace.TracerProvider interface is too narrow. The only method that is defined is the get_tracer abstract method. The examples and documentation recommend acquiring a provider using opentelementry.trace.get_tracer_provider() and then calling method on it to add span processors amongst other operations. For example, the cookbook example for Manually setting span context:
The SDK implementation class (opentelemetry.sdk.trace.TracerProvider) implements theadd_span_processor method but it is not available on opentelemetry.trace.TracerProvider. This causes errors in static type analysis tools since the type returned from opentelemetry.trace.get_tracer_provider() is opentelemetry.trace.TracerProvider. I think that the ABC should define abstract implementations of get_tracer and add_span_processor.
Would an PR be welcome here? I'm not sure if exposing already implemented methods on the public API is a change of the API surface or not.
<string>:4: error: "TracerProvider" has no attribute "add_span_processor" [attr-defined]
Found 1 error in 1 file (checked 1 source file)
Additional context
This is the underlying issue behind #2988, and #3713. I opened a new issue since the others seem to have lost momentum. Feel free to close this one as a duplicate of the others as long as the typing discrepancies are fixed 😉
Would you like to implement a fix?
I could as long as the API change is acceptable.
The text was updated successfully, but these errors were encountered:
Describe your environment
OS: macOS
Python version: Python 3.12.2
SDK version: 1.31.0
API version: 1.31.0
What happened?
The
opentelemetry.trace.TracerProvider
interface is too narrow. The only method that is defined is theget_tracer
abstract method. The examples and documentation recommend acquiring a provider usingopentelementry.trace.get_tracer_provider()
and then calling method on it to add span processors amongst other operations. For example, the cookbook example for Manually setting span context:The SDK implementation class (
opentelemetry.sdk.trace.TracerProvider
) implements theadd_span_processor
method but it is not available onopentelemetry.trace.TracerProvider
. This causes errors in static type analysis tools since the type returned fromopentelemetry.trace.get_tracer_provider()
isopentelemetry.trace.TracerProvider
. I think that the ABC should define abstract implementations ofget_tracer
andadd_span_processor
.Would an PR be welcome here? I'm not sure if exposing already implemented methods on the public API is a change of the API surface or not.
Steps to Reproduce
Expected Result
No type failures
Actual Result
Additional context
This is the underlying issue behind #2988, and #3713. I opened a new issue since the others seem to have lost momentum. Feel free to close this one as a duplicate of the others as long as the typing discrepancies are fixed 😉
Would you like to implement a fix?
I could as long as the API change is acceptable.
The text was updated successfully, but these errors were encountered: