Skip to content

Commit 3204988

Browse files
authored
fix(rum): enable selective disabling of RUM per location (#34)
Fixes RUM configuration inheritance using std::optional 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:** ```apache DatadogRum On <DatadogRumSettings> DatadogRumOption applicationId abc123 </DatadogRumSettings> <Location /health> DatadogRum Off # Now works correctly </Location> ```
1 parent ce4fd1b commit 3204988

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

mod_datadog/src/rum/config.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ std::string make_rum_json_config(
7878

7979
const char* enable_rum_ddog(cmd_parms* /* cmd */, void* cfg, int value) {
8080
auto* dir_conf = static_cast<Directory*>(cfg);
81-
dir_conf->rum.enabled = (bool)value;
81+
dir_conf->rum.enabled = static_cast<bool>(value);
8282
return NULL;
8383
}
8484

@@ -178,7 +178,9 @@ namespace datadog::rum::conf {
178178

179179
void merge_directory_configuration(Directory& out, const Directory& parent,
180180
const Directory& child) {
181-
out.enabled = child.enabled || parent.enabled;
181+
// If child explicitly set enabled, use child's value; otherwise inherit from
182+
// parent
183+
out.enabled = child.enabled.has_value() ? child.enabled : parent.enabled;
182184
out.snippet = child.snippet ? child.snippet : parent.snippet;
183185
out.app_id_tag =
184186
child.app_id_tag.empty() ? parent.app_id_tag : child.app_id_tag;

mod_datadog/src/rum/config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <optional>
34
#include <string>
45
#include <unordered_map>
56

@@ -26,7 +27,7 @@ AP_INIT_TAKE_ARGV("DatadogRumOption", reinterpret_cast<cmd_func>(set_rum_option)
2627
namespace datadog::rum::conf {
2728

2829
struct Directory final {
29-
bool enabled = false;
30+
std::optional<bool> enabled; // nullopt = inherit from parent
3031
Snippet* snippet = nullptr;
3132
std::string version;
3233
std::unordered_map<std::string, std::string> config;

mod_datadog/src/rum/filter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ int rum_output_filter(ap_filter_t* f, apr_bucket_brigade* bb) {
9696
auto* dir_conf = static_cast<Directory*>(
9797
ap_get_module_config(r->per_dir_config, &datadog_module));
9898

99-
if (!dir_conf->rum.enabled || dir_conf->rum.snippet == nullptr) {
99+
// Only inject if explicitly enabled
100+
if (dir_conf->rum.enabled != true || dir_conf->rum.snippet == nullptr) {
100101
return ap_pass_brigade(f->next, bb);
101102
}
102103

0 commit comments

Comments
 (0)