From cba6fdfc3bc734c5f8435f612d62f0cb35635082 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Mon, 9 Sep 2024 16:17:13 +0100 Subject: [PATCH 1/2] Fix double question mark in http.target --- .../Processors/ElasticCompatibilityProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elastic.OpenTelemetry/Processors/ElasticCompatibilityProcessor.cs b/src/Elastic.OpenTelemetry/Processors/ElasticCompatibilityProcessor.cs index d48e53c..fd7f7b6 100644 --- a/src/Elastic.OpenTelemetry/Processors/ElasticCompatibilityProcessor.cs +++ b/src/Elastic.OpenTelemetry/Processors/ElasticCompatibilityProcessor.cs @@ -88,7 +88,7 @@ public override void OnEnd(Activity activity) var target = urlPath; if (urlQuery is not null) - target += $"?{urlQuery}"; + target += urlQuery; SetStringAttribute(HttpTarget, target); } From ac59bc554faa33c15b40999209a766341f0b1e09 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Mon, 9 Sep 2024 18:32:05 +0100 Subject: [PATCH 2/2] Update test case --- .../Processors/ElasticCompatibilityProcessorTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Elastic.OpenTelemetry.Tests/Processors/ElasticCompatibilityProcessorTests.cs b/tests/Elastic.OpenTelemetry.Tests/Processors/ElasticCompatibilityProcessorTests.cs index 0b7ba49..e4ac163 100644 --- a/tests/Elastic.OpenTelemetry.Tests/Processors/ElasticCompatibilityProcessorTests.cs +++ b/tests/Elastic.OpenTelemetry.Tests/Processors/ElasticCompatibilityProcessorTests.cs @@ -74,7 +74,7 @@ public void AddsExpectedHttpAttributes_WhenUrlQuery_IsPresent() { const string scheme = "https"; const string path = "/my/path"; - const string query = "q=OpenTelemetry"; + const string query = "?q=OpenTelemetry"; var activity = _activitySource.CreateActivity("test", ActivityKind.Server)!; @@ -87,7 +87,7 @@ public void AddsExpectedHttpAttributes_WhenUrlQuery_IsPresent() // We can test with Tags (rather than TagObjects) here as we know these are string values activity.Tags.Single(t => t.Key == TraceSemanticConventions.HttpScheme).Value.Should().Be(scheme); - activity.Tags.Single(t => t.Key == TraceSemanticConventions.HttpTarget).Value.Should().Be($"{path}?{query}"); + activity.Tags.Single(t => t.Key == TraceSemanticConventions.HttpTarget).Value.Should().Be($"{path}{query}"); } public void Dispose()