Skip to content

Commit

Permalink
ref: Improve isSentryRequestUrl (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed May 8, 2023
1 parent 94e8e06 commit ce90464
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions otel/internal/utils/sentryrequest.go
Expand Up @@ -38,6 +38,10 @@ func isSentryRequestUrl(ctx context.Context, url string) bool {
return false
}

dsn, _ := sentry.NewDsn(client.Options().Dsn)
return strings.Contains(url, dsn.GetHost()) && strings.Contains(url, dsn.GetProjectID())
dsn, err := sentry.NewDsn(client.Options().Dsn)
if err != nil {
return false
}

return strings.Contains(url, dsn.GetAPIURL().String())
}
2 changes: 1 addition & 1 deletion otel/span_processor_test.go
Expand Up @@ -313,7 +313,7 @@ func TestOnEndDoesNotFinishSentryRequests(t *testing.T) {
emptyContextWithSentry(),
"POST to Sentry",
// Hostname is same as in Sentry DSN
trace.WithAttributes(attribute.String("http.url", "https://example.com/123")),
trace.WithAttributes(attribute.String("http.url", "https://example.com/api/123/envelope/")),
)
sentrySpan, _ := sentrySpanMap.Get(otelSpan.SpanContext().SpanID())
otelSpan.End()
Expand Down

0 comments on commit ce90464

Please sign in to comment.