Skip to content

Commit

Permalink
[fix][query] Filter out tracing for access to static UI assets (#6374)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Fixes #6265

## Description of the changes
- Adds a filter from `xconfighttp` to ignore accesses to static UI
assets at `/static/*`

## Testing
I ran the monitor example and accessed the Jaeger UI to test that the
traces were getting recorded on main but not in this PR.

### On main
```
curl -s "http://localhost:16686/api/traces?service=jaeger" | jq -r '.data[].spans[] | select(.operationName | startswith("/static")) | .operationName'
/static/jaeger-logo-CNZsoUdk.svg
/static/index-bzTJ6oK_.css
/static/index-BDRwFQ_z.js
```
### This PR 
```
curl -s "http://localhost:16686/api/traces?service=jaeger" | jq -r '.data[].spans[] | select(.operationName | startswith("/static")) | .operationName'
```

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 authored Dec 18, 2024
1 parent 376061e commit ebf84c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
9 changes: 9 additions & 0 deletions cmd/query/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import (
"io"
"net"
"net/http"
"path"
"strings"
"sync"

"github.com/soheilhy/cmux"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componentstatus"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/confighttp/xconfighttp"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
Expand Down Expand Up @@ -219,6 +222,12 @@ func createHTTPServer(
MeterProvider: telset.MeterProvider,
},
handler,
xconfighttp.WithOtelHTTPOptions(
otelhttp.WithFilter(func(r *http.Request) bool {
ignorePath := path.Join("/", queryOpts.BasePath, "static")
return !strings.HasPrefix(r.URL.Path, ignorePath)
}),
),
)
if err != nil {
return nil, errors.Join(err, staticHandlerCloser.Close())
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ require (
go.opentelemetry.io/collector/config/configauth v0.116.0
go.opentelemetry.io/collector/config/configgrpc v0.116.0
go.opentelemetry.io/collector/config/confighttp v0.116.0
go.opentelemetry.io/collector/config/confighttp/xconfighttp v0.116.0
go.opentelemetry.io/collector/config/configretry v1.22.0
go.opentelemetry.io/collector/config/configtls v1.22.0
go.opentelemetry.io/collector/confmap v1.22.0
Expand Down Expand Up @@ -202,7 +203,7 @@ require (
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
Expand Down Expand Up @@ -278,7 +279,7 @@ require (
golang.org/x/text v0.21.0 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241216192217-9240e9c98484 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down Expand Up @@ -635,6 +635,8 @@ go.opentelemetry.io/collector/config/configgrpc v0.116.0 h1:O8Y1X9wDH5dDdqDJ9kqo
go.opentelemetry.io/collector/config/configgrpc v0.116.0/go.mod h1:RPrSQrr6xhIaAK2DdcECi142NjSo0npQfVQB3nommSo=
go.opentelemetry.io/collector/config/confighttp v0.116.0 h1:MLI88LmGzlN5D4pH6nFMg5hU3UCeTZb72iVx1lWb0c8=
go.opentelemetry.io/collector/config/confighttp v0.116.0/go.mod h1:iJzNYVOiE1V3lpOIZIkR3JJk3aX/RGp9+SEssJMJ/bY=
go.opentelemetry.io/collector/config/confighttp/xconfighttp v0.116.0 h1:0s7Z7cHx50M6OJdWt9PgXklImUkAF2MVmWiClnj/zB8=
go.opentelemetry.io/collector/config/confighttp/xconfighttp v0.116.0/go.mod h1:FYunjrmzqrTQ53Z3VGbZ9xcR3ewbRWEupp8151T1CQI=
go.opentelemetry.io/collector/config/confignet v1.22.0 h1:SBEMHJZWD8J4qgFw1O+BEkXW9AWldDi6Fz5YeDeoU58=
go.opentelemetry.io/collector/config/confignet v1.22.0/go.mod h1:ZppUH1hgUJOubawEsxsQ9MzEYFytqo2GnVSS7d4CVxc=
go.opentelemetry.io/collector/config/configopaque v1.22.0 h1:CJgsm/Ynr2JE5Y66hYJBdybjHs20ywHtBHiV1jlI4yE=
Expand Down Expand Up @@ -944,8 +946,8 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 h1:CkkIfIt50+lT6NHAVoRYEyAvQGFM7xEwXUUywFvEb3Q=
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576/go.mod h1:1R3kvZ1dtP3+4p4d3G8uJ8rFk/fWlScl38vanWACI08=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 h1:8ZmaLZE4XWrtU3MyClkYqqtl6Oegr3235h7jxsDyqCY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241216192217-9240e9c98484 h1:Z7FRVJPSMaHQxD0uXU8WdgFh8PseLM8Q8NzhnpMrBhQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241216192217-9240e9c98484/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
Expand Down

0 comments on commit ebf84c1

Please sign in to comment.