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

Remove global set_tracer_provider from trace pipelines #156

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gruebel
Copy link
Contributor

@gruebel gruebel commented Jan 23, 2025

Changes

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@gruebel gruebel requested a review from a team as a code owner January 23, 2025 23:35
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.

Project coverage is 54.0%. Comparing base (4d9b52f) to head (04ddf6b).

Files with missing lines Patch % Lines
...elemetry-contrib/src/trace/exporter/jaeger_json.rs 0.0% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #156     +/-   ##
=======================================
- Coverage   54.1%   54.0%   -0.1%     
=======================================
  Files         42      42             
  Lines       6282    6261     -21     
=======================================
- Hits        3400    3386     -14     
+ Misses      2882    2875      -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -49,7 +49,7 @@ impl<R: JaegerJsonRuntime> JaegerJsonExporter<R> {
}

/// Install the exporter using the internal provided runtime
pub fn install_batch(self) -> Tracer {
pub fn install_batch(self) -> (Tracer, TracerProvider) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this need to return the provider only. The caller then can create Tracer using the returned provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about that, but my problem is the InstrumentationScope which is defined here and used to setup the tracer. Any advice on how to handle it? Or should I also remove it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove it. The instrumentation scope is expected to capture the component emitting the traces, so whoever is emitting traces, they should call provider.tracer("component-name"), and use that tracer, rather than creating a tracer with hardcoded name here. (OpenTelemetry-OTLP was also doing this mistake - it was returning a tracer with hardcode named "otel-otlp", which defeats the purpose of InstrumentationScope, as every telemetry would be associated incorrectly with "otel-otlp", instead of reflecting the component)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @cijothomas I did as asked, please have an other look again.

@@ -295,7 +295,7 @@ impl DatadogPipelineBuilder {
.with_attributes(None)
.build();
let tracer = provider.tracer_with_scope(scope);
let _ = global::set_tracer_provider(provider.clone());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return provider only, not tracer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants