Activities were getting closed with incorrect duration #1432
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
While using @qhris (thank you 🙏 ) work before it was published, we started to notice a weird pattern for the metrics.
Our current setup has a .NET Framework ASP.NET application instrumented with OpenTelemetry dotnet client, and we needed to have the metrics tagged with route information, so that we are able to support grafana dashboards over it (we haven't found a way to do it over trace information). We are also using OTEL to feed the connected App Insights instance.
As soon as we packed and deployed the code, due to the high load the system is subjected to (10M+ requests/day) we noticed a saw tooth pattern on the reported graphs in AppInsights and Grafana.
As you can see on the above, we have several thousand requests being saved with a duration of ~1ms. We also have the following:
Sorry for the redacted services names.
Fixes #1431 .
Changes
I reverted
ActivityHelper
to 895a9c7.Since this breaks the enrichment logic developed in #1407 (this was already address in #1425 ), I've added the duration computation logic into the
HttpInMetricsListener
(not the best place I know, but). I've tried to "import" most of the code fromActivity
, to have high precision.Next steps
I would like to further improve the code and add unit tests, but to be clear my knowledge on this (ASP.NET lifecycle pipelines) is very limited to what Microsoft (still) has on their documentation pages, so I would request aid to understand the unit test case and to work on it.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes