-
Notifications
You must be signed in to change notification settings - Fork 771
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
Creating CompositePropagator #923
Conversation
src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 Report
@@ 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
|
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; |
There was a problem hiding this comment.
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? 🤷
test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CustomPropagator1.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Api/Context/Propagation/TraceContextFormat.cs
Outdated
Show resolved
Hide resolved
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 <[email protected]> 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) |
There was a problem hiding this comment.
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.
test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs
Show resolved
Hide resolved
test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs
Outdated
Show resolved
Hide resolved
…ynaka/opentelemetry-dotnet into feature/composite-propagator
Assert.Contains(carrier, kv => kv.Key == "custom-traceparent"); | ||
|
||
bool isInjected = compositePropagator.IsInjected(carrier, Getter); | ||
Assert.True(isInjected); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs
Show resolved
Hide resolved
test/OpenTelemetry.Tests/Implementation/Trace/Propagation/CompositePropagatorTest.cs
Outdated
Show resolved
Hide resolved
…ynaka/opentelemetry-dotnet into feature/composite-propagator
@MikeGoldsmith I merged this to make progress - please let us know if your comments are not addressed. We can follow up. Thanks! |
Fixes #582.
Changes
ITextFormat.Extract
to acceptActivityContext
based on the specification: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#extractCompositePropagator
based on the specification: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#create-a-composite-propagatorTraceContextActivityTest
)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: