Skip to content

Commit

Permalink
Fix OTEL HTTP exclusion detection (#1688)
Browse files Browse the repository at this point in the history
* Fix OTEL HTTP exclusion detection

* Fix grpc and add traces too

* add unit test

(cherry picked from commit dabf256)
  • Loading branch information
mariomac authored and grafana-delivery-bot[bot] committed Feb 21, 2025
1 parent 1e6be4e commit 4c3eca3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/internal/request/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func (s *Span) isMetricsExportURL() bool {
case EventTypeGRPCClient:
return strings.HasPrefix(s.Path, grpcMetricsDetectPattern)
case EventTypeHTTPClient:
return strings.HasPrefix(s.Path, metricsDetectPattern)
return strings.HasSuffix(s.Path, metricsDetectPattern)
default:
return false
}
Expand All @@ -501,7 +501,7 @@ func (s *Span) isTracesExportURL() bool {
case EventTypeGRPCClient:
return strings.HasPrefix(s.Path, grpcTracesDetectPattern)
case EventTypeHTTPClient:
return strings.HasPrefix(s.Path, tracesDetectPattern)
return strings.HasSuffix(s.Path, tracesDetectPattern)
default:
return false
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/internal/request/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,15 @@ func TestDetectsOTelExport(t *testing.T) {
exports: false,
},
{
name: "Successfull HTTP /v1/metrics spans export",
name: "Successful HTTP /v1/metrics spans export",
span: Span{Type: EventTypeHTTPClient, Method: "GET", Path: "/v1/metrics", RequestStart: 100, End: 200, Status: 200},
exports: true,
},
{
name: "Successful HTTP /prefix/v1/metrics spans export",
span: Span{Type: EventTypeHTTPClient, Method: "GET", Path: "/prefix/v1/metrics", RequestStart: 100, End: 200, Status: 200},
exports: true,
},
{
name: "GRPC server spans don't export",
span: Span{Type: EventTypeGRPC, Method: "GET", Path: "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", RequestStart: 100, End: 200, Status: 0},
Expand Down

0 comments on commit 4c3eca3

Please sign in to comment.