Skip to content

Commit

Permalink
Fix double question mark in http.target (#157)
Browse files Browse the repository at this point in the history
As titled
  • Loading branch information
stevejgordon authored Sep 10, 2024
1 parent 410d127 commit 2d47f7e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)!;

Expand All @@ -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()
Expand Down

0 comments on commit 2d47f7e

Please sign in to comment.