Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][query] Filter out tracing for access to static UI assets #6374

Merged
merged 7 commits into from
Dec 18, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Dec 17, 2024

Which problem is this PR solving?

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

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.18%. Comparing base (376061e) to head (0d882a1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6374      +/-   ##
==========================================
- Coverage   96.20%   96.18%   -0.03%     
==========================================
  Files         361      361              
  Lines       20600    20604       +4     
==========================================
- Hits        19819    19818       -1     
- Misses        597      601       +4     
- Partials      184      185       +1     
Flag Coverage Δ
badger_v1 8.96% <ø> (ø)
badger_v2 1.63% <ø> (ø)
cassandra-4.x-v1-manual 14.93% <ø> (ø)
cassandra-4.x-v2-auto 1.57% <ø> (ø)
cassandra-4.x-v2-manual 1.57% <ø> (ø)
cassandra-5.x-v1-manual 14.93% <ø> (ø)
cassandra-5.x-v2-auto 1.57% <ø> (ø)
cassandra-5.x-v2-manual 1.57% <ø> (ø)
elasticsearch-6.x-v1 18.62% <ø> (+<0.01%) ⬆️
elasticsearch-7.x-v1 18.69% <ø> (-0.01%) ⬇️
elasticsearch-8.x-v1 18.86% <ø> (+<0.01%) ⬆️
elasticsearch-8.x-v2 1.63% <ø> (+<0.01%) ⬆️
grpc_v1 10.61% <ø> (ø)
grpc_v2 7.95% <ø> (+<0.01%) ⬆️
kafka-v1 9.29% <ø> (ø)
kafka-v2 1.63% <ø> (ø)
memory_v2 1.62% <ø> (ø)
opensearch-1.x-v1 18.75% <ø> (ø)
opensearch-2.x-v1 18.74% <ø> (-0.01%) ⬇️
opensearch-2.x-v2 1.63% <ø> (ø)
tailsampling-processor 0.45% <ø> (ø)
unittests 95.07% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -219,6 +222,12 @@ func createHTTPServer(
MeterProvider: telset.MeterProvider,
},
handler,
xconfighttp.WithOtelHTTPOptions(
otelhttp.WithFilter(func(r *http.Request) bool {
ignorePaths := regexp.MustCompile(`^/static/.*`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. ^/static/.* does not require regex, can be matched with strings.HasPrefix
  2. it doesn't look like it will work if the UI is running with a custom base path, we need to account for that too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro for 2 - do we want to do a contains to see if the /static path is anywhere in the URL?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be a bit fuzzy. I would rather use HasPrefix with basePath + "/static/"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git diff cmd/jaeger/config.yaml

   jaeger_query:
+    base_path: /foobar
     storage:
       traces: some_store
       traces_archive: another_store
$ go run ./cmd/jaeger --config ./cmd/jaeger/config.yaml

Reload UI a few times, observe span /foobar/static/favicon-BxcVf0am.ico

So, not solved.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro apologies - i forgot to push my commits

@yurishkuro yurishkuro enabled auto-merge (squash) December 18, 2024 03:39
@yurishkuro yurishkuro merged commit ebf84c1 into jaegertracing:main Dec 18, 2024
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Access to UI static assets should not be traced
2 participants