-
Notifications
You must be signed in to change notification settings - Fork 393
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4693 +/- ##
=======================================
Coverage 97.64% 97.64%
=======================================
Files 1470 1470
Lines 87707 87742 +35
Branches 4547 4551 +4
=======================================
+ Hits 85644 85680 +36
+ Misses 2063 2062 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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.
@@ -552,6 +552,7 @@ cache.read('city') | |||
| --------------- | - | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | | |||
| `enabled` | `DD_TRACE_ACTIVE_SUPPORT_ENABLED` | `Bool` | Whether the integration should create spans. | `true` | | |||
| `cache_service` | | `String` | Name of application running the `active_support` instrumentation. May be overridden by `global_default_service_name`. [See _Additional Configuration_ for more details](#additional-configuration) | `active_support-cache` | | |||
| `cache_store` | | `Array` | Specifies which cache stores to instrument. Accepts a list of store names (e.g. `memory_store`, `file_store`, or symbols like `:file_store`). If set, only the listed stores will be traced. By default (`nil`), it traces all stores. | `nil` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `cache_store` | | `Array` | Specifies which cache stores to instrument. Accepts a list of store names (e.g. `memory_store`, `file_store`, or symbols like `:file_store`). If set, only the listed stores will be traced. By default (`nil`), it traces all stores. | `nil` | | |
| `cache_store` | | `Array` | Specifies which cache stores to instrument. Accepts an array of store names such as `memory_store`, `file_store`, or symbols like `:file_store`. If set, only the listed stores are traced. Defaults to `nil`, which traces all stores. | `nil` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the option be in plural, i.e. cache_stores
?
BenchmarksBenchmark execution time: 2025-05-28 19:56:58 Comparing candidate commit c1ef3f8 in PR branch Found 1 performance improvements and 2 performance regressions! Performance is the same for 37 metrics, 5 unstable metrics. scenario:profiling - Allocations ()
scenario:tracing - Propagation - Trace Context
scenario:tracing - Tracing.log_correlation
|
@@ -552,6 +552,7 @@ cache.read('city') | |||
| --------------- | - | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | | |||
| `enabled` | `DD_TRACE_ACTIVE_SUPPORT_ENABLED` | `Bool` | Whether the integration should create spans. | `true` | | |||
| `cache_service` | | `String` | Name of application running the `active_support` instrumentation. May be overridden by `global_default_service_name`. [See _Additional Configuration_ for more details](#additional-configuration) | `active_support-cache` | | |||
| `cache_store` | | `Array` | Specifies which cache stores to instrument. Accepts a list of store names (e.g. `memory_store`, `file_store`, or symbols like `:file_store`). If set, only the listed stores will be traced. By default (`nil`), it traces all stores. | `nil` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the option be in plural, i.e. cache_stores
?
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 |
There was a problem hiding this comment.
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 dup
ed during assignment? Otherwise this would mutate their data.
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:
['file_store', :memory_store]
).How to test the change?
:cache_store
includes, excludes, or is unset for various backends.Datadog.configure { |c| c.tracing.instrument :active_support, cache_store: [:file_store] }
and verify that only the specified store is traced.