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

Add GlobalPropagators API and have instrumentation default to it #1428

Merged

Conversation

cijothomas
Copy link
Member

Fixes #581

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

@cijothomas cijothomas requested a review from a team October 30, 2020 20:31
{
private static PropagationContext defaultPropagationContext = default;

public override ISet<string> Fields => null;
Copy link
Member Author

Choose a reason for hiding this comment

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

anything better than null?

/// </summary>
public static TextMapPropagator DefaultTextMapPropagator { get; set; } = new NoOpTextMapPropagator();

internal static void Reset()
Copy link
Member Author

Choose a reason for hiding this comment

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

for tests only.

Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

LGTM.

@codecov
Copy link

codecov bot commented Oct 30, 2020

Codecov Report

Merging #1428 into master will decrease coverage by 0.09%.
The diff coverage is 74.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1428      +/-   ##
==========================================
- Coverage   81.85%   81.75%   -0.10%     
==========================================
  Files         227      229       +2     
  Lines        6089     6095       +6     
==========================================
- Hits         4984     4983       -1     
- Misses       1105     1112       +7     
Impacted Files Coverage Δ
...y.Api/Context/Propagation/NoopTextMapPropagator.cs 0.00% <0.00%> (ø)
.../OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs 0.00% <0.00%> (ø)
src/OpenTelemetry/Trace/TracerProviderSdk.cs 95.00% <ø> (-0.13%) ⬇️
src/OpenTelemetry/Sdk.cs 84.61% <80.00%> (-15.39%) ⬇️
...enTelemetry.Api/Context/Propagation/Propagators.cs 100.00% <100.00%> (ø)
...rumentation.AspNet/AspNetInstrumentationOptions.cs 100.00% <100.00%> (ø)
...umentation.AspNet/Implementation/HttpInListener.cs 88.65% <100.00%> (+0.23%) ⬆️
...ion.AspNetCore/AspNetCoreInstrumentationOptions.cs 100.00% <100.00%> (ø)
...mentation.Http/HttpClientInstrumentationOptions.cs 100.00% <100.00%> (ø)
....Prometheus/PrometheusExporterMetricsHttpServer.cs 74.50% <0.00%> (-1.97%) ⬇️
... and 3 more

@CodeBlanch
Copy link
Member

I have some comments about the API on the issue. I'll probably be in the minority on this one but basically, I'm seeing some inconsistency between having a builder for most things and a static global for this. If a user has multiple TracerProviders, with different propagation schemes, then what is the effect of something setting Propagators.DefaultTextMapPropagator = some_propagator via the API? Is their intention to override all active TracerProviders, or some specific one?

I feel like the API we should provide is like SetResource, which is also a global-yet-scoped type of thing...

            using var tracerProvider = Sdk.CreateTracerProviderBuilder()
                .SetResource(new Resource(...))
                .SetPropagator(new CompositePropagator(...))
                .Build();

In API we would have to provide some way to discover active TracerProviders and their state (default propagator, resource, etc.) like 'TracerProviders.Active[0].DefaultPropagator = some_propagator`.

✌️ 🕊️ ❤️

new TraceContextPropagator(),
new BaggagePropagator(),
});
public TextMapPropagator Propagator { get; set; } = Propagators.DefaultTextMapPropagator;
Copy link
Member

Choose a reason for hiding this comment

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

Could be a timing thing here. When options are created they'll copy the ref for the current default propagator. If user sets through SDK the global propagator after that, it won't be reflected. Could leave it null here and then when it is used in instrumentation do options.Propagator ?? Propagators.DefaultTextMapPropagator. It would be a slight perf hit but it makes it hot-swappable.

@cijothomas
Copy link
Member Author

Merging.
More discussion are live on this, so expect follow up PRs soon

@cijothomas cijothomas merged commit 0979259 into open-telemetry:master Nov 3, 2020
@cijothomas cijothomas deleted the cijothomas/globalpropagator1 branch November 3, 2020 04:40
@alanwest alanwest mentioned this pull request Jan 12, 2021
3 tasks
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.

Add Global Propagators API
3 participants