-
Notifications
You must be signed in to change notification settings - Fork 730
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 ActivityContextFormat and propagation #724
Add ActivityContextFormat and propagation #724
Conversation
…hub.com/cijothomas/opentelemetry-dotnet into cijothomas/activity3adapter1a_alternate
…hub.com/cijothomas/opentelemetry-dotnet into cijothomas/activity3adapter1a_alternate
Make Asp.Net instrumentation work with Activity API
…it tests and this is not planned to be in this repo as well.
…hub.com/cijothomas/opentelemetry-dotnet into cijothomas/activity3adapter1a_alternate
using OpenTelemetry.Context.Propagation; | ||
using Xunit; | ||
|
||
namespace OpenTelemetry.Impl.Trace.Propagation |
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.
nit: Rename "Impl" -> "Implementation" in namespace. I think "Impl" was used a lot before but we're been slowly cleaning it up?
test/OpenTelemetry.Instrumentation.Dependencies.Tests/HttpClientTests.Basic.netcore31.cs
Show resolved
Hide resolved
activity.Kind, | ||
activity.Tags, | ||
activity.Links); | ||
activity.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.
nit: Extra tab thing going on here? Also at the end of the method (line 121) spacing looks off. Sorry for even mentioning it just happened to catch my eye.
src/OpenTelemetry.Instrumentation.AspNet.Win/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNet.Win/Implementation/HttpInListener.cs
Show resolved
Hide resolved
@@ -59,12 +59,14 @@ public void Dispose() | |||
// [InlineData("http://localhost/api/value", 0, null, "/api/value")] // Request will be filtered | |||
// [InlineData("http://localhost/api/value", 0, null, "{ThrowException}")] // Filter user code will throw an exception | |||
[InlineData("http://localhost/api/value/2", 0, null, "CustomContext", "/api/value")] // Request will not be filtered | |||
[InlineData("http://localhost/api/value/2", 0, null, "CustomContext", "/api/value", true)] // Request will not be filtered |
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.
This tests for both cases now? Awesome!
// then we need to retrieve the one created by HttpInListener | ||
// and stop it. | ||
var activityByHttpInListener = (Activity)activity.GetCustomProperty("ActivityByHttpInListener"); | ||
activityByHttpInListener.Stop(); |
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.
One last thing :) When we stop "newOne" here do we need to restore Activity.Current back to libraryActivity (since the Stop will call Activity.SetCurrent(Parent)
)? Something like:
else if (activity.OperationName.Equals("Microsoft.AspNet.HttpReqIn.Start"))
{
// This block is hit if Asp.Net did restore Current to its own activity,
// then we need to retrieve the one created by HttpInListener
// and stop it.
var activityByHttpInListener = (Activity)activity.GetCustomProperty("ActivityByHttpInListener");
activityByHttpInListener.Stop();
Activity.Current = activity; // Put back libraryActivity
}
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.
Right. Added tests too for this.
Merging this now to make another PR on top of this. |
Following up on #701, this PR adds ITextFormatActivity and TraceContextFormatActivity which can extract/inject ActivityContext (similar to SpanContext).
TODO: as another follow up:
When instrumentation adapter creates new activity(), this results in a duplicate telemetry collection. This will be fixed as a follow up, along with fixing the custom Filter. (the new instrumentationadapters dont support Filters)
Changes
Introduce ITextFormatActivity and TraceContextFormatActivity
Modify instrumentation adapter to extract context using above - the activity which did not use the above(i.e Asp.Net, Asp.Net Core), will be ignored and a new one is started.
Checklist
For significant contributions please make sure you have completed the following items:
The PR will automatically request reviews from code owners and trigger CI build and tests.