diff options
author | Sourabh Shirhatti <shirhatti@outlook.com> | 2021-09-29 20:17:13 +0300 |
---|---|---|
committer | Sourabh Shirhatti <shirhatti@outlook.com> | 2021-09-29 20:17:13 +0300 |
commit | 4053fe51e80cb24ec7aeadc9e1737c84254a1295 (patch) | |
tree | 643f4d0581d4c2a9ee76e8b88d6c783c24b4847e | |
parent | 60721d45c169a8958975121edd35a2ec10f7f9c3 (diff) |
OTel HTTP Semantic conventionsshirhatti/otel-http-semantic-conventions
-rw-r--r-- | src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs index 595267f3f8..9b827527e8 100644 --- a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs +++ b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs @@ -26,6 +26,11 @@ namespace Microsoft.AspNetCore.Hosting private const string DeprecatedDiagnosticsEndRequestKey = "Microsoft.AspNetCore.Hosting.EndRequest"; private const string DiagnosticsUnhandledExceptionKey = "Microsoft.AspNetCore.Hosting.UnhandledException"; + private const string HttpSchemeActivityTag = "http.scheme"; + private const string HttpHostActivityTag = "http.host"; + private const string HttpTargetActivityTag = "http.target"; + private const string HttpStatusCodeActivityTag = "http.status_code"; + private readonly ActivitySource _activitySource; private readonly DiagnosticListener _diagnosticListener; private readonly DistributedContextPropagator _propagator; @@ -159,6 +164,9 @@ namespace Microsoft.AspNetCore.Hosting // Always stop activity if it was started if (activity is not null) { + // Add required tags before stopping + activity.AddTag(HttpStatusCodeActivityTag, httpContext.Response.StatusCode); + StopActivity(httpContext, activity, context.HasDiagnosticListener); } @@ -319,6 +327,11 @@ namespace Microsoft.AspNetCore.Hosting } } + // Add requisite tags before starting + activity.AddTag(HttpSchemeActivityTag, httpContext.Request.Scheme); + activity.AddTag(HttpHostActivityTag, httpContext.Request.Host); + activity.AddTag(HttpTargetActivityTag, httpContext.Request.Path); + _diagnosticListener.OnActivityImport(activity, httpContext); if (_diagnosticListener.IsEnabled(ActivityStartKey)) |