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

Creating CompositePropagator #923

Merged
merged 18 commits into from
Aug 5, 2020
Merged

Creating CompositePropagator #923

merged 18 commits into from
Aug 5, 2020

Conversation

eddynaka
Copy link
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
Copy link
Member

@CodeBlanch CodeBlanch left a comment

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
Copy link
Member

@cijothomas cijothomas left a comment

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.

Copy link
Member

@cijothomas cijothomas left a comment

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?

@codecov
Copy link

codecov bot commented Jul 29, 2020

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
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
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? 🤷

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
@@ -157,7 +156,7 @@ public void Inject<T>(ActivityContext activityContext, T carrier, Action<T, stri
}
}

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
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
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
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
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