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

Rename of Propagators #1427

Conversation

cijothomas
Copy link
Member

@cijothomas cijothomas commented Oct 30, 2020

Renamed TextMapPropagator to TraceContextPropagator, CompositePropapagor
to CompositeTextMapPropagator. IPropagator is renamed to TextMapPropagator
and changed from interface to abstract class.

In prep for #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 18:28
/// </summary>
public sealed class B3Propagator : IPropagator
public sealed class B3Propagator : ITextMapPropagator
Copy link
Member

@reyang reyang Oct 30, 2020

Choose a reason for hiding this comment

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

Do we want an interface ITextMapPropagator or an abstract class TextMapPropagator?
Interface gives benefit of multi-inheritance, which I don't see a useful scenario here (an extreme case would be having TraceContextPropagator implementing both the text and binary interface).
On the other side interface forbids us from adding optional methods in the future (will have to introduce ITextMapPropagator2, ITextMapPropagator3, ...).

Copy link
Member Author

Choose a reason for hiding this comment

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

yes i was thinking.. and agree :)

Copy link
Member

Choose a reason for hiding this comment

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

Base class seems like a good idea.

Just FYI as of C#8 you can add default implementation on an interface. Check out: https://devblogs.microsoft.com/dotnet/default-implementations-in-interfaces/

I haven't ever used it, but it's there 😄

Copy link
Member

Choose a reason for hiding this comment

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

Makes me wondering - if we have class Foobar: IFoo, IBar:

  1. Both IFoo and IBar decided to add a new default implementation and they share the same name 😂
  2. IFoo used to have IFoo.SayHello and now IBar decided to add the same thing 😢

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to abstract base class now. We follow same approach for others part in SDK, like base processor, exporter etc.

@codecov
Copy link

codecov bot commented Oct 30, 2020

Codecov Report

Merging #1427 into master will increase coverage by 0.57%.
The diff coverage is 75.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1427      +/-   ##
==========================================
+ Coverage   81.31%   81.89%   +0.57%     
==========================================
  Files         227      227              
  Lines        6117     6086      -31     
==========================================
+ Hits         4974     4984      +10     
+ Misses       1143     1102      -41     
Impacted Files Coverage Δ
...metryProtocol/Implementation/ActivityExtensions.cs 86.89% <47.36%> (+13.06%) ⬆️
.../Context/Propagation/CompositeTextMapPropagator.cs 81.81% <66.66%> (ø)
....Api/Context/Propagation/TraceContextPropagator.cs 76.23% <76.23%> (ø)
...try.Exporter.OpenTelemetryProtocol/OtlpExporter.cs 58.97% <85.00%> (+30.40%) ⬆️
...nTelemetry.Api/Context/Propagation/B3Propagator.cs 85.86% <100.00%> (ø)
...metry.Api/Context/Propagation/BaggagePropagator.cs 83.92% <100.00%> (ø)
...orter.OpenTelemetryProtocol/OtlpExporterOptions.cs 100.00% <100.00%> (ø)
...rumentation.AspNet/AspNetInstrumentationOptions.cs 100.00% <100.00%> (ø)
...umentation.AspNet/Implementation/HttpInListener.cs 88.42% <100.00%> (ø)
...ion.AspNetCore/AspNetCoreInstrumentationOptions.cs 100.00% <100.00%> (ø)
... and 6 more

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.

private const string TraceParent = "traceparent";
private const string TraceState = "tracestate";

private static readonly int VersionPrefixIdLength = "00-".Length;
Copy link
Member

Choose a reason for hiding this comment

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

not blocking this PR, I wonder if we could use const instead of readonly.

private const string TraceState = "tracestate";

private static readonly int VersionPrefixIdLength = "00-".Length;
private static readonly int TraceIdLength = "0af7651916cd43dd8448eb211c80319c".Length;
Copy link
Member

Choose a reason for hiding this comment

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

not blocking this PR, the official name (according to the TraceContext spec) should be ParentId instead of TraceId.

Copy link
Member Author

Choose a reason for hiding this comment

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

This TraceId is TraceId itself in TraceContext spec. ParentId is what we call SpanId. But spec says "Span-id" is alternate name for parentid.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I was looking at a wrong place, meant to say SpanIdLength should be ParentIdLength.

@cijothomas cijothomas merged commit 4975fb0 into open-telemetry:master Oct 30, 2020
@cijothomas cijothomas deleted the cijothomas/renametoitextmappropagator branch October 30, 2020 19:20
private static readonly int SpanIdLength = "00f067aa0ba902b7".Length;
private static readonly int VersionAndTraceIdAndSpanIdLength = "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-".Length;
private static readonly int OptionsLength = "00".Length;
private static readonly int TraceparentLengthV0 = "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-00".Length;
Copy link
Member

Choose a reason for hiding this comment

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

This one probably can be TraceParent instead of Traceparent (we've finished the long time debate).

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.

4 participants