Skip to content

Duration is not being counted for properly [.NET Framework 4.8 Metrics & Telemetry Module] #1431

Open
@carlos-neto-maersk

Description

@carlos-neto-maersk

Issue with OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule

List of all OpenTelemetry NuGet
packages
and version that you are
using (e.g. OpenTelemetry 1.3.2):

  <package id="OpenTelemetry.Api" version="1.6.0" targetFramework="net48" />
  <package id="OpenTelemetry.Api.ProviderBuilderExtensions" version="1.6.0" targetFramework="net48" />
  <package id="OpenTelemetry.Exporter.Console" version="1.6.0" targetFramework="net48" />
  <package id="OpenTelemetry.Exporter.OpenTelemetryProtocol" version="1.5.0-rc.1" targetFramework="net48" />
  <package id="OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs" version="1.5.0-rc.1" targetFramework="net48" />
  <package id="OpenTelemetry.Extensions.Hosting" version="1.6.0" targetFramework="net48" />
  <package id="OpenTelemetry.Instrumentation.AspNet" version="1.6.0-beta.1.20" targetFramework="net48" />
  <package id="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule" version="1.6.0-beta.1.22" targetFramework="net48" />
  <package id="OpenTelemetry.Instrumentation.Http" version="1.6.0-beta.2" targetFramework="net48" />
  <package id="OpenTelemetry.Instrumentation.SqlClient" version="1.5.1-beta.1" targetFramework="net48" />
  <package id="OpenTelemetry.PersistentStorage.Abstractions" version="1.0.0" targetFramework="net48" />
  <package id="OpenTelemetry.PersistentStorage.FileSystem" version="1.0.0" targetFramework="net48" />

OpenTelemetry.Instrumentation.AspNet and OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule is a packed by us version that contains the code in main + the merged code from #1425 and #1407 and #1388.

Runtime version (e.g. net462, net48, net6.0, net7.0 etc. You can
find this information from the *.csproj file):

  • net48

Is this a feature request or a bug?

  • Feature Request
  • Bug

What is the expected behavior?

What do you expect to see?
Request duration being properly logged and average, p95 times do not have strange pattern.
We are running unpublished but already merged code from #1425 and #1407 and #1388.
These were all done by the same author, whom I would like to leave the biggest word of gratitude because it is being so helpful.

What is the actual behavior?

What did you see instead?

We can see on Azure App service metrics that everything is okay, but App insights, fed by OpenTelemetry exporter, is reporting this pattern on the performance view. We also see a lot of requests being exported with a duration of ~ 1ms, with their span children having the correct duration traced.
Screenshot 2023-11-10 at 15 53 55
Screenshot 2023-11-10 at 15 54 20

Additional Context

I'm looking at the ActivityHelper.StopAspNetActivity as the possible root cause. If I'm able to find any way to fix it, I'll open a PR here for you guys. In the meanwhile, help would be very much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions