- Notifications
You must be signed in to change notification settings - Fork5.2k
Add ActivitySource support to DiagnosticsHandler#54437
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedJun 18, 2021
Tagging subscribers to this area: @dotnet/ncl Issue DetailsToday,
This PR preserves the same behaviour when no The behaviour changesiff all of the following hold:
In this case, no The PR moves the decision of whether to log events/create an activity out of the // The interesting part of the PR - this method decides on the actual behaviourstaticboolShouldLogDiagnostics(HttpRequestMessagerequest,outActivity?activity) I also removed the internal Note that the PR is only a slight refactor + adding Opening as a draft so the diagnostics team can confirm whether the above is the desired behaviour with
|
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
tarekgh left a comment
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. Thanks!
MihaZupan commentedJun 21, 2021
@dotnet/ncl please take a look at this PR - the behaviour should be unchanged, but there is a considerable refactor to the underlying class. |
| privatestaticreadonlyDiagnosticListeners_diagnosticListener=new("HttpHandlerDiagnosticListener"); | ||
| privatestaticreadonlyActivitySources_activitySource=new(Namespace); | ||
| publicstaticreadonlyboolIsGloballyEnabled=GetEnableActivityPropagationValue(); |
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 needs to be static property or it will regress feature switch setting and increases size duo to static ctor dependency
MihaZupanJun 23, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Changed to
publicstaticboolIsGloballyEnabled{get;}= GetEnableActivityPropagationValue();
@marek-safar Is this the pattern you had in mind?
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.
I think it's better but it will still all the unnecessary dependencies like DiagnosticListener, ActivitySource and others where were not there before. You can check the size regression to see how much it adds
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.
Is there a linker switch forDiagnosticsHandler?
Or was it capable of removing the code before (it would have had to removeActivity andDiagnosticListener)?
You can check the size regression to see how much it adds
Do you mean just the size of theSystem.Net.Http assembly? Or some other way of looking at trimmed regressions?
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.
Is there a linker switch for DiagnosticsHandler?
Yes, see HttpActivityPropagationSupport athttps://github.com/dotnet/runtime/blob/main/docs/workflow/trimming/feature-switches.md
Do you mean just the size of the System.Net.Http assembly? Or some other way of looking at trimmed regressions?
System.Net.Http will probably show the biggest increase if there is some. You can publish trimmed release build with HttpActivityPropagationSupport property set to false to compare.
MihaZupanJun 23, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
I updated theILLink.Substitutions.xml toget_IsGloballyEnabled().
Looking at.\build.cmd -projects .\src\libraries\System.Net.Http\src\System.Net.Http.csproj -os Browser -c Release
the size ofSystem.Net.Http.dll inbrowser-wasm\lib\net6.0 dropped from 247.296 to 246.272 bytes after this PR.
I don't know how to test the runtime change with trimming and the feature switch.
noahfalk left a comment
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.
I had a few questions around what our desired behavior should be inline. Other than that all looked good : )
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
geoffkizer left a comment
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.
These changes look reasonable to me. I'd suggest changing the "when" usage (as I commented above), but it's not a huge deal.
noahfalk left a comment
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!
dotnet#54437 but without the ActivitySource support
Today,
DiagnosticsHandlerwill create a newActivityif either is true:Activitywas already set (Activity.Currentis not null)DiagnosticListenerrequested one (was enabled for the activity name)This PR preserves the same behaviour when no
ActivityListeneris present.The behaviour changesiff all of the following hold:
Activitywas already set (Activity.Currentwas not null)DiagnosticListenerwas enabled for the activity nameActivitySourcehad listeners presentIn this case, no
Activityis created (and so we also won't inject context headers).If a
DiagnosticListeneris enabled for the activity, one is always created (regardless of sampling decisions).The PR moves the decision of whether to log events/create an activity out of the
SendAsynccall intoI also removed the internal
SettingsandLoggingStringsclasses - am I missing something and they actually provide value?Note that the PR is only a slight refactor + adding
ActivitySource. It does not address other knownDiagnosticsHandlerissues.This is runtime's equivalent of whatdotnet/aspnetcore#30089 was for AspNet.
Opening as a draft so the diagnostics team can confirm whether the above is the desired behaviour with
ActivitySource.cc:@shirhatti@tarekgh@noahfalk