-
Notifications
You must be signed in to change notification settings - Fork 167
fix(tracing): fix tracer provider initialization logic #381
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -935,29 +935,38 @@ def _has_existing_trace_provider() -> bool: | |||||||||||
| return True | ||||||||||||
|
|
||||||||||||
| def _get_ot_tracer_inner() -> ot_trace.Tracer: | ||||||||||||
| if _has_existing_trace_provider(): | ||||||||||||
| enable_report = _str_to_bool(os.getenv("TRACE_ENABLE_REPORT", "false")) | ||||||||||||
| enable_debug = _str_to_bool(os.getenv("TRACE_ENABLE_DEBUG", "false")) | ||||||||||||
|
|
||||||||||||
| if enable_report and _has_existing_trace_provider(): | ||||||||||||
|
||||||||||||
| if enable_report and _has_existing_trace_provider(): | |
| # Reuse an existing tracer provider whenever tracing is enabled | |
| # (report or debug), preserving the original behavior of reusing | |
| # any previously configured provider. | |
| if (enable_report or enable_debug) and _has_existing_trace_provider(): |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Create TracerProvider if either report or debug is enabled" which accurately describes the condition on line 945. However, consider adding a comment for the else block at line 968-969 to clarify that a NoOpTracerProvider is used when tracing is completely disabled, as this is an important aspect of the initialization logic.
| else: | |
| else: | |
| # Use a NoOpTracerProvider when both reporting and debug tracing are disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case for this?
If the user has already configured a trace_provider at the beginning, do they still need to additionally set TRACE_ENABLE_REPORT in order to reuse the existing trace_provider?
If so, that seems rather odd. The user has already configured the trace_provider according to the OpenTelemetry specification (In our cases), but now they also need to learn or inspect the code to discover that there is an additional TRACE_ENABLE_REPORT environment variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main point is this: if the user has already configured a global trace_provider in their code (and has likely also set up the corresponding exporter), shouldn't the system follow that configuration by default? It seems unnecessar to require the user to additionally set the TRACE_ENABLE_REPORT environment variable in order to activate logic that leverages an already-configured trace_provider.