Skip to content

Creating CompositePropagator - #923

Merged
cijothomas merged 18 commits into
open-telemetry:masterfrom
eddynaka:feature/composite-propagator
Aug 5, 2020
Merged

Creating CompositePropagator#923
cijothomas merged 18 commits into
open-telemetry:masterfrom
eddynaka:feature/composite-propagator

Conversation

@eddynaka

Copy link
Copy Markdown
Contributor

Fixes #582.

Changes

Thanks to @CodeBlanch and @cijothomas for the guidance!

Please provide a brief description of the changes here. Update the
CHANGELOG.md for non-trivial changes.

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

  • Design discussion issue #
  • Changes in public API reviewed

@eddynaka
eddynaka requested a review from a team July 24, 2020 23:50
Comment thread src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs Outdated

@CodeBlanch CodeBlanch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@reyang reyang added the pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package label Jul 25, 2020
Comment thread src/OpenTelemetry.Api/Context/Propagation/ITextFormat.cs Outdated
Comment thread src/OpenTelemetry.Api/Context/Propagation/TraceContextFormat.cs

@cijothomas cijothomas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to get more clarity either from this PR or from spec before merging.

Comment thread src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs
Comment thread src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs Outdated
Comment thread src/OpenTelemetry.Api/Context/Propagation/ITextFormat.cs Outdated
Comment thread src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs Outdated

@cijothomas cijothomas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My main concern is alleviated. I'd love to see more unit tests validating the behavior in all scenarios.
Also, this is a breaking change from beta - could you update changelog with this info?

@cijothomas
cijothomas requested a review from MikeGoldsmith July 29, 2020 05:10
@codecov

codecov Bot commented Jul 29, 2020

Copy link
Copy Markdown

Codecov Report

Merging #923 into master will increase coverage by 0.13%.
The diff coverage is 70.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #923      +/-   ##
==========================================
+ Coverage   68.28%   68.42%   +0.13%     
==========================================
  Files         219      220       +1     
  Lines        5976     5989      +13     
  Branches      978      981       +3     
==========================================
+ Hits         4081     4098      +17     
- Misses       1618     1619       +1     
+ Partials      277      272       -5     
Impacted Files Coverage Δ
...umentation.AspNet/Implementation/HttpInListener.cs 0.00% <0.00%> (ø)
...tation.AspNetCore/Implementation/HttpInListener.cs 76.92% <50.00%> (-0.30%) ⬇️
src/OpenTelemetry/Context/Propagation/B3Format.cs 65.78% <66.66%> (ø)
...etry.Api/Context/Propagation/TraceContextFormat.cs 55.26% <72.22%> (+5.69%) ⬆️
...try.Api/Context/Propagation/CompositePropagator.cs 73.33% <73.33%> (ø)
src/OpenTelemetry.Api/Trace/SpanContext.cs 61.90% <100.00%> (+1.90%) ⬆️
src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs 96.96% <100.00%> (+12.59%) ⬆️
src/OpenTelemetry/Metrics/CounterMetricSdkBase.cs 80.00% <0.00%> (-13.34%) ⬇️
... and 1 more

@eddynaka

Copy link
Copy Markdown
Contributor Author

My main concern is alleviated. I'd love to see more unit tests validating the behavior in all scenarios.
Also, this is a breaking change from beta - could you update changelog with this info?

Sure! just updated and added a reference to spec

/// Converts a <see cref="SpanContext"/> into an <see cref="ActivityContext"/>.
/// </summary>
/// <param name="spanContext"><see cref="SpanContext"/> source.</param>
public static implicit operator ActivityContext(SpanContext spanContext) => spanContext.ActivityContext;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cijothomas I'm thinking about dropping implicit casts on all the shim classes. Why do that? Not sure. It just feels like a good thing to have. Could reduce bugs in places where we don't consider the Span case because we focus more on the Activity case? The idea is to allow Span version to be passed anywhere Activity version can be passed. How do you feel about that? 🤷

Comment thread test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CustomPropagator1.cs Outdated
Comment thread src/OpenTelemetry.Api/CHANGELOG.md
Comment thread src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs Outdated
Comment thread src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs Outdated
Comment thread src/OpenTelemetry.Api/Context/Propagation/ITextFormat.cs Outdated
Comment thread src/OpenTelemetry.Api/Context/Propagation/TraceContextFormat.cs Outdated
eddynaka and others added 5 commits July 31, 2020 07:31
Adding ActivityContext to interface

Adding tests

Updating CompositePropagator + tests

updating comments

Improving performance when size is 0

updating tests

updating default tracestate for empty

MikeGoldsmith review

adding more tests to exemplify usage

Feature/composite propagator refactor (#1)

* Added TestPropagator and switched a couple tests to use it.

* removing extra classes

Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>

updating changelog and constructor

MikeGoldsmith comments

updating logic
}

private bool TryExtractTraceparent(string traceparent, out ActivityTraceId traceId, out ActivitySpanId spanId, out ActivityTraceFlags traceOptions)
internal static bool TryExtractTraceparent(string traceparent, out ActivityTraceId traceId, out ActivitySpanId spanId, out ActivityTraceFlags traceOptions)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks to @CodeBlanch we'll get better help from .NET Activity API to do the parsing etc in the Rc1 release. We can refactor some of the code here at that time.

Assert.Contains(carrier, kv => kv.Key == "custom-traceparent");

bool isInjected = compositePropagator.IsInjected(carrier, Getter);
Assert.True(isInjected);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lets validate that while injecting with 2 propagators using same key, the last one wins? There is no requirement that the 2nd one checks that header already exist and backs off right?

Same with extract - validate that we return when we find the 1st valid context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For the inject part: ok, i did some changes that will validate the value and check if the latest one is the one that we have.
For the isInjected part: all will have to be injected. Since i did one with same header and one with different ones. i think we are covered.
For the extract part: changed the constructor to pass a boolean, so we can define if we will return a default or not. With that in mind, I counted how many times we used the Getter. So, if the first one returns default, we have to access only two times.

@cijothomas
cijothomas merged commit 8948470 into open-telemetry:master Aug 5, 2020
@cijothomas

Copy link
Copy Markdown
Member

@MikeGoldsmith I merged this to make progress - please let us know if your comments are not addressed. We can follow up. Thanks!

@eddynaka
eddynaka deleted the feature/composite-propagator branch August 14, 2020 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Composite Propagator

5 participants