fix(rum): enable selective disabling of RUM per location#34
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #34 +/- ##
=======================================
Coverage 62.43% 62.43%
=======================================
Files 7 7
Lines 370 370
Branches 49 49
=======================================
Hits 231 231
Misses 101 101
Partials 38 38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
/codex review |
|
|
||
| struct Directory final { | ||
| bool enabled = false; | ||
| // -1 = not set (inherit from parent), 0 = explicitly disabled, 1 = |
Contributor
There was a problem hiding this comment.
I would rather use an enum class, such as, for example:
enum class Enable_status {
Unset,
Enabled,
Disabled
};
struct Directory final {
Enabled_status enabled = Enable_status::Unset;
| // enabled: -1 = not set, 0 = Off, 1 = On | ||
| // If child explicitly set enabled (not -1), use child's value | ||
| // Otherwise, inherit from parent | ||
| out.enabled = (child.enabled != -1) ? child.enabled : parent.enabled; |
Contributor
There was a problem hiding this comment.
Using an enum class as proposed below, this would be:
out.enabled = (child.enabled != Enable_status::Unset) ? child.enabled : parent.enabled;
| if (!dir_conf->rum.enabled || dir_conf->rum.snippet == nullptr) { | ||
| // enabled: -1 = not set, 0 = Off, 1 = On | ||
| // Only inject if explicitly enabled (1) | ||
| if (dir_conf->rum.enabled != 1 || dir_conf->rum.snippet == nullptr) { |
Contributor
There was a problem hiding this comment.
“Only inject if explicitly enabled (1)” should rather be dir_conf->rum.enabled == 1 (or dir_conf->rum.enabled == Enable_status::Enabled).
ffa23ca to
791d4c9
Compare
Use std::optional<bool> for RUM enable status to distinguish between "not set" (inherit from parent) and "explicitly disabled". This allows child locations to selectively disable RUM injection even when parent has it enabled.
791d4c9 to
e58c230
Compare
Contributor
Author
|
I used the std::optional in lieu of the enum - thanks for the revie! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes RUM configuration inheritance using type-safe
enum class Enable_status.Previously, child locations couldn't disable RUM when parent enabled it due to OR-based merge (
child || parent).Enum values:
Unset= inherit from parent (default)Disabled= explicitly disabled (DatadogRum Off)Enabled= explicitly enabled (DatadogRum On)Example: