From bd902438c93998c709c26508627ab555f95e07e3 Mon Sep 17 00:00:00 2001 From: lu-xiaoshuang <121755080+lu-xiaoshuang@users.noreply.github.com> Date: Mon, 11 Mar 2024 08:00:00 +0800 Subject: [PATCH] align endpoint to java version --- .../Handlers/DefaultHostingDiagnosticHandler.cs | 5 +++-- .../Handlers/DefaultRequestDiagnosticHandler.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/SkyApm.Diagnostics.AspNetCore/Handlers/DefaultHostingDiagnosticHandler.cs b/src/SkyApm.Diagnostics.AspNetCore/Handlers/DefaultHostingDiagnosticHandler.cs index 1c9266a4..2ee9878a 100644 --- a/src/SkyApm.Diagnostics.AspNetCore/Handlers/DefaultHostingDiagnosticHandler.cs +++ b/src/SkyApm.Diagnostics.AspNetCore/Handlers/DefaultHostingDiagnosticHandler.cs @@ -53,7 +53,8 @@ public bool OnlyMatch(HttpContext request) public void BeginRequest(ITracingContext tracingContext, HttpContext httpContext) { - var context = tracingContext.CreateEntrySegmentContext(httpContext.Request.Path, + var context = tracingContext.CreateEntrySegmentContext( + httpContext.Request.Method.ToUpper() + ":" + httpContext.Request.Path, new HttpRequestCarrierHeaderCollection(httpContext.Request)); context.Span.SpanLayer = SpanLayer.HTTP; context.Span.Component = Common.Components.ASPNETCORE; @@ -167,4 +168,4 @@ private string CollectBody(HttpContext httpContext, int lengthThreshold) } } } -} \ No newline at end of file +} diff --git a/src/SkyApm.Diagnostics.HttpClient/Handlers/DefaultRequestDiagnosticHandler.cs b/src/SkyApm.Diagnostics.HttpClient/Handlers/DefaultRequestDiagnosticHandler.cs index 0a4419b3..bd553cfe 100644 --- a/src/SkyApm.Diagnostics.HttpClient/Handlers/DefaultRequestDiagnosticHandler.cs +++ b/src/SkyApm.Diagnostics.HttpClient/Handlers/DefaultRequestDiagnosticHandler.cs @@ -47,7 +47,7 @@ public bool OnlyMatch(HttpRequestMessage request) public void Handle(ITracingContext tracingContext, HttpRequestMessage request) { - var operationName = request.RequestUri.GetLeftPart(UriPartial.Path); + var operationName = request.RequestUri.GetComponents(UriComponents.Path | UriComponents.KeepDelimiter, UriFormat.UriEscaped); var ignored = _httpClientDiagnosticConfig.IgnorePaths != null && _httpClientDiagnosticConfig.IgnorePaths @@ -115,4 +115,4 @@ private string CollectHeaders(HttpRequestMessage request, IEnumerable ke return sb.ToString(); } } -} \ No newline at end of file +}