Skip to content

fix(rum): enable selective disabling of RUM per location#34

Merged
pawelchcki merged 1 commit into
mainfrom
pawel/rum-config-fix
Jan 29, 2026
Merged

fix(rum): enable selective disabling of RUM per location#34
pawelchcki merged 1 commit into
mainfrom
pawel/rum-config-fix

Conversation

@pawelchcki
Copy link
Copy Markdown
Contributor

@pawelchcki pawelchcki commented Jan 27, 2026

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:

DatadogRum On
<DatadogRumSettings>
  DatadogRumOption applicationId abc123
</DatadogRumSettings>

<Location /health>
  DatadogRum Off  # Now works correctly
</Location>

@pawelchcki pawelchcki requested a review from a team as a code owner January 27, 2026 14:32
@pawelchcki pawelchcki requested review from cataphract and removed request for a team January 27, 2026 14:32
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.43%. Comparing base (ce4fd1b) to head (e58c230).
⚠️ Report is 1 commits behind head on main.

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.
📢 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.

@pawelchcki
Copy link
Copy Markdown
Contributor Author

/codex review

Comment thread mod_datadog/src/rum/config.h Outdated

struct Directory final {
bool enabled = false;
// -1 = not set (inherit from parent), 0 = explicitly disabled, 1 =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

or std::optional

Comment thread mod_datadog/src/rum/config.cpp Outdated
// 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;
Copy link
Copy Markdown
Contributor

@xlamorlette-datadog xlamorlette-datadog Jan 27, 2026

Choose a reason for hiding this comment

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

Using an enum class as proposed below, this would be:

out.enabled = (child.enabled != Enable_status::Unset) ? child.enabled : parent.enabled;

Comment thread mod_datadog/src/rum/filter.cpp Outdated
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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

“Only inject if explicitly enabled (1)” should rather be dir_conf->rum.enabled == 1 (or dir_conf->rum.enabled == Enable_status::Enabled).

Copy link
Copy Markdown
Contributor

@dmehala dmehala left a comment

Choose a reason for hiding this comment

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

LGTM.

@pawelchcki pawelchcki force-pushed the pawel/rum-config-fix branch 2 times, most recently from ffa23ca to 791d4c9 Compare January 29, 2026 13:40
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.
@pawelchcki pawelchcki force-pushed the pawel/rum-config-fix branch from 791d4c9 to e58c230 Compare January 29, 2026 14:07
@pawelchcki
Copy link
Copy Markdown
Contributor Author

I used the std::optional in lieu of the enum - thanks for the revie!

@pawelchcki pawelchcki merged commit 3204988 into main Jan 29, 2026
5 checks passed
@pawelchcki pawelchcki deleted the pawel/rum-config-fix branch January 29, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants