-
Notifications
You must be signed in to change notification settings - Fork 5k
HttpClient spans don't show up as exemplars #103893
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
Comments
Update: I do see HttpClient spans show up as exemplars for some metrics: For example, the points here are correctly HttpClient spans: But HttpClient spans don't show up in It seems like it is important to always end a duration metric before its associated activity so exemplars work. Is that correct @reyang? |
Yes. OTel's instrumentation library is reporting metric while Activity is still active, though that has some hacky behavior as it relies on activity duration, which is not normally available unless activity itself ends! |
If you are doing... builder.SetExemplarFilter(ExemplarFilterType.TraceBased) Then yes there will need to be an active trace ( There are other filters (and an envvar for histograms) you can use which will generate exemplars for all measurements but if there is no PS: ❤️ the visualization in the dashboard. |
I think the case here is - the HttpClient activity is ended, but the Asp.Net Core one is still active, so Exempalr will still link to the right traceid |
@JamesNK would it make sense if I would send you a private build of |
Ok. Update to date main branch is fine. This is a recent daily .NET 9 SDK I installed - 9.0.100-preview.7.24329.1. I can update to the latest daily .NET 9 SDK if required. |
To write a unit test for this I think you would assert in a Update: See dotnet/aspnetcore#56592 as an example |
@JamesNK built from the current main: System.Net.Http-SwappedTelemetry.zip, PTAL if it does the job! Note that the naive change breaks the ability of registering metrics enrichment callbacks on It may also break other stuff, didn't have a chance yet to investigate the impact fully. |
I don't think we should worry about it. |
I couldn't test this with Aspire for reasons, so I wrote a test app that exports to console: https://github.com/JamesNK/MetricsExemplarsTest 9.0 current (note: no exemplar): 9.0 with custom System.Net.Http (note: has exemplar): It works. |
Uh oh!
There was an error while loading. Please reload this page.
Description
I'm adding a new exemplar feature to the Aspire dashboard. Basically, when a metric is recorded, in-progress spans are included as example data.
However, I never see the HttpClient span as an exemplar. Someone should investigate why and fix this.
I don't know exactly how this feature technically works. However, my theory is the HttpClient span is ended before
http.client.request.duration
recorded, so the HttpClient activity isn't available for opentelemetry-sdk to associate with the metric. The order may need to be flipped: recordhttp.client.request.duration
and then stop the activity. I think it is a matter of making the metrics handler a child of the diagnostics handler here.Reproduction Steps
Capture OTEL data with metrics + exemplars enabled + make HTTP requests with HttpClient.
See dotnet/aspire#4629 for an example.
Expected behavior
HttpClient spans show update as exemplars.
Actual behavior
HttpClient spans are never exemplars.
Regression?
No
Known Workarounds
No response
Configuration
.NET 8
Other information
No response
The text was updated successfully, but these errors were encountered: