Skip to content

Commit b5e01e5

Browse files
bm1549claude
andcommitted
Exclude sensitive configurations from configuration telemetry
Add a `sensitive` flag to the configuration definition (zai_config_entry and its memoized entry) so a DD_* configuration can be marked in its CONFIG(...) declaration in ext/configuration.h. The configuration-telemetry enqueue loop over the DD_* config table skips entries whose flag is set; DD_API_KEY and DD_TRACE_ENABLED carry it. Remove the OTLP header configurations (OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_METRICS_HEADERS, OTEL_EXPORTER_OTLP_LOGS_HEADERS) from the OpenTelemetry SDK configuration whitelist so they are not tracked for telemetry. Derive the "sensitive": true markers in metadata/supported-configurations.json from the flag in ext/configuration.h, plus the OTLP header variants the generator lists. Add a .phpt test and extend the loader functional test to assert these configuration values do not appear in the enqueued configuration telemetry while non-sensitive configurations remain reported. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 46641ee commit b5e01e5

11 files changed

Lines changed: 296 additions & 10 deletions

File tree

ext/configuration.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ enum datadog_sidecar_connection_mode {
4545
CONFIG(STRING, DD_AGENT_HOST, "localhost", .ini_change = zai_config_system_ini_change) \
4646
CONFIG(STRING, DD_DOGSTATSD_URL, "http://localhost:8125") \
4747
CONFIG(STRING, DD_DOGSTATSD_HOST, "localhost") \
48-
CONFIG(STRING, DD_API_KEY, "", .ini_change = zai_config_system_ini_change) \
48+
CONFIG(STRING, DD_API_KEY, "", .ini_change = zai_config_system_ini_change, .sensitive = true) \
4949
CONFIG(INT, DD_DOGSTATSD_PORT, "8125") \
5050
CONFIG(STRING, DD_ENV, "", .ini_change = datadog_alter_dd_env, \
5151
.env_config_fallback = ddtrace_conf_otel_resource_attributes_env) \
@@ -59,7 +59,7 @@ enum datadog_sidecar_connection_mode {
5959
CONFIG(BOOL, DD_TRACE_CLI_ENABLED, "true") \
6060
CONFIG(BOOL, DD_TRACE_DEBUG, "false", .ini_change = datadog_alter_dd_trace_debug) \
6161
CONFIG(BOOL, DD_TRACE_ENABLED, "true", .ini_change = datadog_alter_dd_trace_disabled_config, \
62-
.env_config_fallback = ddtrace_conf_otel_traces_exporter) \
62+
.env_config_fallback = ddtrace_conf_otel_traces_exporter, .sensitive = true) \
6363
CONFIG(BOOL, DD_INSTRUMENTATION_TELEMETRY_ENABLED, "true", .ini_change = zai_config_system_ini_change) \
6464
CONFIG(BOOL, DD_TRACE_HEALTH_METRICS_ENABLED, "false", .ini_change = zai_config_system_ini_change) \
6565
CONFIG(DOUBLE, DD_TRACE_HEALTH_METRICS_HEARTBEAT_SAMPLE_RATE, "0.001") \

ext/telemetry.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ void datadog_telemetry_finalize() {
9898
#if ZTS
9999
ini = zend_hash_find_ptr(EG(ini_directives), ini->name);
100100
#endif
101-
if (cfg->names[0].len != sizeof("DD_TRACE_ENABLED") - 1
102-
|| memcmp(cfg->names[0].ptr, "DD_TRACE_ENABLED", sizeof("DD_TRACE_ENABLED") - 1) != 0) { // DD_TRACE_ENABLED is meaningless: always off at rshutdown
101+
if (!cfg->sensitive) {
103102
ddog_ConfigurationOrigin origin = DDOG_CONFIGURATION_ORIGIN_ENV_VAR;
104103
switch (cfg->name_index) {
105104
case ZAI_CONFIG_ORIGIN_DEFAULT:

loader/tests/functional/test_configuration_telemetry.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
'DD_INJECT_FORCE=true',
1212
'DD_INJECTION_ENABLED=tracer', // Normally set by the injector
1313
'DD_SERVICE=loader',
14+
'DD_API_KEY=SENTINEL_DD_API_KEY',
15+
'DD_VERSION=1.2.3-loader-test',
1416
]);
1517

1618
assertMatchesFormat($output, '%A"loaded_by_ssi":true%s%A');
@@ -22,3 +24,13 @@
2224
assertContains($content, '{"name":"instrumentation_source","value":"ssi","origin":"default","config_id":null,"seq_id":null}');
2325
assertContains($content, '{"name":"ssi_injection_enabled","value":"tracer","origin":"env_var","config_id":null,"seq_id":null}');
2426
assertContains($content, '{"name":"ssi_forced_injection_enabled","value":"True","origin":"env_var","config_id":null,"seq_id":null}');
27+
28+
// Sensitive configurations are excluded from configuration telemetry: neither
29+
// the name nor the value is enqueued. DD_API_KEY and DD_TRACE_ENABLED carry the
30+
// `sensitive` flag.
31+
assertNotContains($content, 'SENTINEL_DD_API_KEY');
32+
assertNotContains($content, '"name":"DD_API_KEY"');
33+
assertNotContains($content, '"name":"DD_TRACE_ENABLED"');
34+
35+
// Non-sensitive configurations are still reported.
36+
assertContains($content, '{"name":"DD_VERSION","value":"1.2.3-loader-test","origin":"env_var","config_id":null,"seq_id":null}');

metadata/supported-configurations.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
{
1313
"implementation": "C",
1414
"type": "string",
15-
"default": ""
15+
"default": "",
16+
"sensitive": true
1617
}
1718
],
1819
"DD_API_SECURITY_ENABLED": [
@@ -1103,7 +1104,8 @@
11031104
{
11041105
"implementation": "A",
11051106
"type": "boolean",
1106-
"default": "true"
1107+
"default": "true",
1108+
"sensitive": true
11071109
}
11081110
],
11091111
"DD_TRACE_EXEC_ANALYTICS_ENABLED": [

profiling/src/bindings/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ pub struct ZaiConfigEntry {
701701
pub parser: zai_custom_parse,
702702
pub displayer: zai_custom_display,
703703
pub env_config_fallback: zai_env_config_fallback,
704+
pub sensitive: bool,
704705
}
705706

706707
#[repr(C)]
@@ -717,6 +718,7 @@ pub struct ZaiConfigMemoizedEntry {
717718
pub parser: zai_custom_parse,
718719
pub displayer: zai_custom_display,
719720
pub env_config_fallback: zai_env_config_fallback,
721+
pub sensitive: bool,
720722
pub original_on_modify: Option<
721723
unsafe extern "C" fn(
722724
entry: *mut zend_ini_entry,

profiling/src/config.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
10191019
parser: Some(parse_profiling_enabled),
10201020
displayer: Some(display_profiling_enabled),
10211021
env_config_fallback: None,
1022+
sensitive: false,
10221023
},
10231024
zai_config_entry {
10241025
id: transmute::<ConfigId, u16>(ProfilingExperimentalFeaturesEnabled),
@@ -1031,6 +1032,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
10311032
parser: None,
10321033
displayer: None,
10331034
env_config_fallback: None,
1035+
sensitive: false,
10341036
},
10351037
zai_config_entry {
10361038
id: transmute::<ConfigId, u16>(ProfilingEndpointCollectionEnabled),
@@ -1043,6 +1045,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
10431045
parser: None,
10441046
displayer: None,
10451047
env_config_fallback: None,
1048+
sensitive: false,
10461049
},
10471050
zai_config_entry {
10481051
id: transmute::<ConfigId, u16>(ProfilingExperimentalCpuTimeEnabled),
@@ -1055,6 +1058,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
10551058
parser: None,
10561059
displayer: None,
10571060
env_config_fallback: None,
1061+
sensitive: false,
10581062
},
10591063
zai_config_entry {
10601064
id: transmute::<ConfigId, u16>(ProfilingAllocationEnabled),
@@ -1067,6 +1071,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
10671071
parser: None,
10681072
displayer: None,
10691073
env_config_fallback: None,
1074+
sensitive: false,
10701075
},
10711076
zai_config_entry {
10721077
id: transmute::<ConfigId, u16>(ProfilingAllocationSamplingDistance),
@@ -1079,6 +1084,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
10791084
parser: Some(parse_sampling_distance_filter),
10801085
displayer: None,
10811086
env_config_fallback: None,
1087+
sensitive: false,
10821088
},
10831089
zai_config_entry {
10841090
id: transmute::<ConfigId, u16>(ProfilingExperimentalHeapLiveEnabled),
@@ -1091,6 +1097,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
10911097
parser: None,
10921098
displayer: None,
10931099
env_config_fallback: None,
1100+
sensitive: false,
10941101
},
10951102
zai_config_entry {
10961103
id: transmute::<ConfigId, u16>(ProfilingTimelineEnabled),
@@ -1103,6 +1110,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
11031110
parser: None,
11041111
displayer: None,
11051112
env_config_fallback: None,
1113+
sensitive: false,
11061114
},
11071115
zai_config_entry {
11081116
id: transmute::<ConfigId, u16>(ProfilingExceptionEnabled),
@@ -1115,6 +1123,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
11151123
parser: None,
11161124
displayer: None,
11171125
env_config_fallback: None,
1126+
sensitive: false,
11181127
},
11191128
zai_config_entry {
11201129
id: transmute::<ConfigId, u16>(ProfilingExceptionMessageEnabled),
@@ -1127,6 +1136,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
11271136
parser: None,
11281137
displayer: None,
11291138
env_config_fallback: None,
1139+
sensitive: false,
11301140
},
11311141
zai_config_entry {
11321142
id: transmute::<ConfigId, u16>(ProfilingExceptionSamplingDistance),
@@ -1139,6 +1149,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
11391149
parser: Some(parse_sampling_distance_filter),
11401150
displayer: None,
11411151
env_config_fallback: None,
1152+
sensitive: false,
11421153
},
11431154
zai_config_entry {
11441155
id: transmute::<ConfigId, u16>(ProfilingExperimentalIOEnabled),
@@ -1151,6 +1162,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
11511162
parser: None,
11521163
displayer: None,
11531164
env_config_fallback: None,
1165+
sensitive: false,
11541166
},
11551167
zai_config_entry {
11561168
id: transmute::<ConfigId, u16>(ProfilingLogLevel),
@@ -1163,6 +1175,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
11631175
parser: Some(parse_level_filter),
11641176
displayer: None,
11651177
env_config_fallback: None,
1178+
sensitive: false,
11661179
},
11671180
zai_config_entry {
11681181
id: transmute::<ConfigId, u16>(ProfilingOutputPprof),
@@ -1175,6 +1188,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
11751188
parser: Some(parse_utf8_string),
11761189
displayer: None,
11771190
env_config_fallback: None,
1191+
sensitive: false,
11781192
},
11791193
// At the moment, wall-time cannot be fully disabled. This only
11801194
// controls automatic collection (manual collection is still
@@ -1190,6 +1204,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
11901204
parser: None,
11911205
displayer: None,
11921206
env_config_fallback: None,
1207+
sensitive: false,
11931208
},
11941209
zai_config_entry {
11951210
id: transmute::<ConfigId, u16>(AgentHost),
@@ -1202,6 +1217,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
12021217
parser: Some(parse_utf8_string),
12031218
displayer: None,
12041219
env_config_fallback: None,
1220+
sensitive: false,
12051221
},
12061222
zai_config_entry {
12071223
id: transmute::<ConfigId, u16>(Env),
@@ -1214,6 +1230,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
12141230
parser: Some(parse_utf8_string),
12151231
displayer: None,
12161232
env_config_fallback: None,
1233+
sensitive: false,
12171234
},
12181235
zai_config_entry {
12191236
id: transmute::<ConfigId, u16>(Service),
@@ -1226,6 +1243,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
12261243
parser: Some(parse_utf8_string),
12271244
displayer: None,
12281245
env_config_fallback: None,
1246+
sensitive: false,
12291247
},
12301248
zai_config_entry {
12311249
id: transmute::<ConfigId, u16>(Tags),
@@ -1242,6 +1260,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
12421260
parser: None,
12431261
displayer: None,
12441262
env_config_fallback: None,
1263+
sensitive: false,
12451264
},
12461265
zai_config_entry {
12471266
id: transmute::<ConfigId, u16>(TraceAgentPort),
@@ -1254,6 +1273,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
12541273
parser: Some(parse_utf8_string),
12551274
displayer: None,
12561275
env_config_fallback: None,
1276+
sensitive: false,
12571277
},
12581278
zai_config_entry {
12591279
id: transmute::<ConfigId, u16>(TraceAgentUrl),
@@ -1266,6 +1286,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
12661286
parser: Some(parse_utf8_string),
12671287
displayer: None,
12681288
env_config_fallback: None,
1289+
sensitive: false,
12691290
},
12701291
zai_config_entry {
12711292
id: transmute::<ConfigId, u16>(Version),
@@ -1278,6 +1299,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
12781299
parser: Some(parse_utf8_string),
12791300
displayer: None,
12801301
env_config_fallback: None,
1302+
sensitive: false,
12811303
},
12821304
zai_config_entry {
12831305
id: transmute::<ConfigId, u16>(GitCommitSha),
@@ -1290,6 +1312,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
12901312
parser: Some(parse_utf8_string),
12911313
displayer: None,
12921314
env_config_fallback: None,
1315+
sensitive: false,
12931316
},
12941317
zai_config_entry {
12951318
id: transmute::<ConfigId, u16>(GitRepositoryUrl),
@@ -1302,6 +1325,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
13021325
parser: Some(parse_utf8_string),
13031326
displayer: None,
13041327
env_config_fallback: None,
1328+
sensitive: false,
13051329
},
13061330
]
13071331
};

src/DDTrace/OpenTelemetry/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT',
2424
'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT',
2525
'OTEL_EXPORTER_OTLP_ENDPOINT',
26-
'OTEL_EXPORTER_OTLP_METRICS_HEADERS',
27-
'OTEL_EXPORTER_OTLP_LOGS_HEADERS',
28-
'OTEL_EXPORTER_OTLP_HEADERS',
26+
// The OTLP header configurations (OTEL_EXPORTER_OTLP_HEADERS,
27+
// OTEL_EXPORTER_OTLP_METRICS_HEADERS, OTEL_EXPORTER_OTLP_LOGS_HEADERS) are
28+
// sensitive and intentionally not tracked for configuration telemetry.
2929
'OTEL_EXPORTER_OTLP_METRICS_TIMEOUT',
3030
'OTEL_EXPORTER_OTLP_LOGS_TIMEOUT',
3131
'OTEL_EXPORTER_OTLP_TIMEOUT',

0 commit comments

Comments
 (0)