-
Notifications
You must be signed in to change notification settings - Fork 394
[NO-TICKET] Improve tracing Rails route computation #4688
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
[NO-TICKET] Improve tracing Rails route computation #4688
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 21681 Passed, 1302 Skipped, 4m 52.24s Total Time |
BenchmarksBenchmark execution time: 2025-06-14 12:34:05 Comparing candidate commit af17fe4 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 41 metrics, 6 unstable metrics. |
lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb
Show resolved
Hide resolved
0380fca
to
4fa9ef9
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4688 +/- ##
==========================================
- Coverage 97.63% 97.63% -0.01%
==========================================
Files 1474 1474
Lines 88022 88026 +4
Branches 4569 4568 -1
==========================================
+ Hits 85942 85944 +2
- Misses 2080 2082 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb
Show resolved
Hide resolved
I'm going to withdraw the part with environment variable, but keep the performance part intact. I've found that we can leverage a little bit of hacks to achieve the same |
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin23] Warming up -------------------------------------- w: gsub 72.280k i/100ms w: sub 81.689k i/100ms w: delete_suffix 502.700k i/100ms w/o: gsub 116.580k i/100ms w/o: sub 195.557k i/100ms w/o: delete_suffix 225.558k i/100ms Calculating ------------------------------------- w: gsub 1.609M (±68.8%) i/s (621.46 ns/i) - 10.914M in 30.723566s w: sub 3.185M (±65.6%) i/s (313.95 ns/i) - 17.481M in 30.198337s w: delete_suffix 4.903M (±118.8%) i/s (203.97 ns/i) - 45.746M in 31.428342s w/o: gsub 4.935M (±64.8%) i/s (202.61 ns/i) - 46.632M in 30.271821s w/o: sub 4.876M (±63.5%) i/s (205.09 ns/i) - 46.934M in 30.233153s w/o: delete_suffix 10.564M (±78.8%) i/s (94.66 ns/i) - 48.495M in 30.639072s
4fa9ef9
to
56643b3
Compare
spec/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation_spec.rb
Show resolved
Hide resolved
@marcotc Will be happy to merge it. I've found tests that covers the change. 🤲🏼 |
What does this PR do?
Drastically improves performance of the code (less allocations, better performance)
Motivation:
In AppSec we need to compute
http.route
-like value of the request and I found that code I can improve.Change log entry
Yes. Tracing: Improve performance of
http.route
tag computation forrails
contrib.Additional Notes:
I've replaced 1 string allocation with mutation and have used faster suffix removal method.
w:
- there is a match in the stringw/o
- there is no match in the stringHow to test the change?
CI + ST