-
Notifications
You must be signed in to change notification settings - Fork 780
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
[.NET7.0] AspNetCore ActivitySource Migration #3391
[.NET7.0] AspNetCore ActivitySource Migration #3391
Conversation
Codecov Report
@@ Coverage Diff @@
## net7.0 #3391 +/- ##
==========================================
- Coverage 86.13% 86.02% -0.11%
==========================================
Files 258 258
Lines 9254 9261 +7
==========================================
- Hits 7971 7967 -4
- Misses 1283 1294 +11
|
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
…ttps://github.com/vishweshbankwar/opentelemetry-dotnet into vibankwa/Net7.0-AspnetCore-ActivitySource-Migration
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentation.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
…tpInListener.cs Co-authored-by: Timothy Mothra <[email protected]>
…ttps://github.com/vishweshbankwar/opentelemetry-dotnet into vibankwa/Net7.0-AspnetCore-ActivitySource-Migration
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
// For .NET6.0 and below, we will continue to use legacy way. | ||
if (HttpInListener.IsNet7OrGreater) | ||
{ | ||
var activitySourceService = serviceProvider?.GetService<ActivitySource>(); |
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.
Not sure if this is safe. Anyone can add ActivitySource
to DI, and how do we know if this is the one added by asp.net core?
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 is how library passes the activitysource as well to diagnostics module. https://github.com/dotnet/aspnetcore/blob/0e5cbf447d329a1e7d69932c3decd1c70a00fbba/src/Hosting/Hosting/src/Internal/WebHost.cs#L152
reference: #3391 (comment)
@@ -135,8 +157,11 @@ public override void OnStartActivity(Activity activity, object payload) | |||
return; | |||
} | |||
|
|||
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, ActivitySource); | |||
ActivityInstrumentationHelper.SetKindProperty(activity, ActivityKind.Server); | |||
if (!IsNet7OrGreater) |
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.
why we have used pre-processor directives (NET7_0_OR_GREATER) in some places and the static variable in other place?
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.
Good point - we should use preprocessor directive everywhere. let me know if there is any case where it wont work
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
// For .NET6.0 and below, we will continue to use legacy way. | ||
#if NET7_0_OR_GREATER | ||
// TODO: Check with .NET team to see if this can be prevented | ||
// as this allows user to override the ActivitySource. |
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.
would be good to write a unittest which simulates this.
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.
Added
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
Fixes #.
#3019
TODO: Add additional tests.
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