[HttpClient and ASP.NET Core] Add note for relying on activity duration for metric data (#4183)
* add note on activity duration * Update src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs Co-authored-by: Reiley Yang <reyang@microsoft.com> * add todo * re --------- Co-authored-by: Reiley Yang <reyang@microsoft.com>
This commit is contained in:
parent
3ad2830d63
commit
69d015eb70
|
|
@ -110,6 +110,9 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
|
|||
}
|
||||
}
|
||||
|
||||
// We are relying here on ASP.NET Core to set duration before writing the stop event.
|
||||
// https://github.com/dotnet/aspnetcore/blob/d6fa351048617ae1c8b47493ba1abbe94c3a24cf/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs#L449
|
||||
// TODO: Follow up with .NET team if we can continue to rely on this behavior.
|
||||
this.httpServerDuration.Record(Activity.Current.Duration.TotalMilliseconds, tags);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeNetPeerPort, request.RequestUri.Port));
|
||||
}
|
||||
|
||||
// We are relying here on HttpClient library to set duration before writing the stop event.
|
||||
// https://github.com/dotnet/runtime/blob/90603686d314147017c8bbe1fa8965776ce607d0/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs#L178
|
||||
// TODO: Follow up with .NET team if we can continue to rely on this behavior.
|
||||
this.httpClientDuration.Record(activity.Duration.TotalMilliseconds, tags);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue