Skip to content

Otel seems to prefer httpTarget over httpRoute #999

Description

@OrkhanAlikhanov

Problem Statement

I'm using go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin together with sentry + otel setup. otelgin seems to set span name correctly to the route /api/v1/projects/:id/issues but sentry otel sets it back to /api/v1/projects/1234/issues which causes transactions not to be grouped properly in the UI.

Solution Brainstorm

When debugging, I see that the code that does this is in these lines:

var httpPath string
if httpTarget != "" {
if parsedUrl, err := url.Parse(httpTarget); err == nil {
// Do not include the query and fragment parts
httpPath = parsedUrl.Path
} else {
httpPath = httpTarget
}
} else if httpRoute != "" {
httpPath = httpRoute
} else if httpUrl != "" {
// This is normally the HTTP-client case
if parsedUrl, err := url.Parse(httpUrl); err == nil {
// Do not include the query and fragment parts
httpPath = fmt.Sprintf("%s://%s%s", parsedUrl.Scheme, parsedUrl.Host, parsedUrl.Path)
}
}

httpTarget takes precedence over httpRoute. I'm not sure what those terms exactly mean in otel context but my goal is to see grouped transactions in the UI

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugIssue typeGoSDK

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions