Skip to content

Add Rails cache store instrumentation filter #4693

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

Merged
merged 3 commits into from
Jul 8, 2025
Merged

Add Rails cache store instrumentation filter #4693

merged 3 commits into from
Jul 8, 2025

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented May 28, 2025

What does this PR do?

This PR introduces a new :cache_store configuration option to the ActiveSupport integration. This option allows users to specify which cache stores should be instrumented by Datadog tracing.

Motivation:

This is important for very fast backends, like MemoryStore, which might not provide useful spans.

Change log entry
Yes. Add :cache_store option to ActiveSupport integration to allow tracing only specified cache backends.

Additional Notes:

  • The option accepts both strings and symbols (e.g., ['file_store', :memory_store]).
  • The default remains unchanged: all cache stores are traced unless this option is set.

How to test the change?

  • Run the test suite, especially the integration tests for ActiveSupport cache instrumentation.
  • Tests cover scenarios where :cache_store includes, excludes, or is unset for various backends.
  • Manual validation: configure Datadog.configure { |c| c.tracing.instrument :active_support, cache_store: [:file_store] } and verify that only the specified store is traced.

@marcotc marcotc self-assigned this May 28, 2025
@marcotc marcotc requested review from a team as code owners May 28, 2025 19:31
@github-actions github-actions bot added integrations Involves tracing integrations tracing labels May 28, 2025
@codecov-commenter
Copy link

codecov-commenter commented May 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.53%. Comparing base (de32d48) to head (2516895).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4693      +/-   ##
==========================================
+ Coverage   97.52%   97.53%   +0.01%     
==========================================
  Files        1484     1484              
  Lines       88624    88660      +36     
  Branches     4598     4602       +4     
==========================================
+ Hits        86431    86475      +44     
+ Misses       2193     2185       -8     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1
Copy link
Contributor

Datadog Report

Branch report: mem-store
Commit report: c1ef3f8
Test service: dd-trace-rb

✅ 0 Failed, 21505 Passed, 1298 Skipped, 4m 7.22s Total Time

Copy link

@drichards-87 drichards-87 left a comment

Choose a reason for hiding this comment

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

Left a suggestion from Docs and approved the PR.

@pr-commenter
Copy link

pr-commenter bot commented May 28, 2025

Benchmarks

Benchmark execution time: 2025-07-08 16:23:05

Comparing candidate commit 2516895 in PR branch mem-store with baseline commit de32d48 in branch master.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 42 metrics, 6 unstable metrics.

scenario:tracing - Propagation - Trace Context

  • 🟥 throughput [-4073.598op/s; -3966.631op/s] or [-10.971%; -10.683%]

o.type :array, nilable: true
o.default nil
o.after_set do |stores|
stores&.map!(&:to_s) # Convert symbols to strings to match the Rails configuration format
Copy link
Member

Choose a reason for hiding this comment

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

Is the customer-supplied array duped during assignment? Otherwise this would mutate their data.

Copy link
Member

Choose a reason for hiding this comment

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

This does mutate customer-supplied array:

irb(main):022> stores=[:foo]
=> [:foo]
irb(main):023> Datadog.configure { |c| c.tracing.instrument :active_support, cache_store: stores }
# ...
irb(main):024> stores
=> ["foo"]

Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Overall looks fine to me, but one suggestion for the configuration option that may be an improvement.

@zarirhamza zarirhamza added this to the 2.19.0 milestone Jul 8, 2025
@zarirhamza zarirhamza merged commit b376cdf into master Jul 8, 2025
632 of 634 checks passed
@zarirhamza zarirhamza deleted the mem-store branch July 8, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants