Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitlab/generate-shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
trap 'rm -f "$BASELINE_CONFIG"' EXIT
cp metadata/supported-configurations.json "$BASELINE_CONFIG"

bash tooling/generate-supported-configurations.sh --self-test
bash tooling/generate-supported-configurations.sh

if ! cmp -s "$BASELINE_CONFIG" metadata/supported-configurations.json; then
Expand Down
2 changes: 1 addition & 1 deletion ext/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum datadog_sidecar_connection_mode {
CONFIG(STRING, DD_AGENT_HOST, "localhost", .ini_change = zai_config_system_ini_change) \
CONFIG(STRING, DD_DOGSTATSD_URL, "http://localhost:8125") \
CONFIG(STRING, DD_DOGSTATSD_HOST, "localhost") \
CONFIG(STRING, DD_API_KEY, "", .ini_change = zai_config_system_ini_change) \
CONFIG(STRING, DD_API_KEY, "", .ini_change = zai_config_system_ini_change, .sensitive = true) \
CONFIG(INT, DD_DOGSTATSD_PORT, "8125") \
CONFIG(STRING, DD_ENV, "", .ini_change = datadog_alter_dd_env, \
.env_config_fallback = ddtrace_conf_otel_resource_attributes_env) \
Expand Down
5 changes: 3 additions & 2 deletions ext/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ void datadog_telemetry_finalize() {
#if ZTS
ini = zend_hash_find_ptr(EG(ini_directives), ini->name);
#endif
if (cfg->names[0].len != sizeof("DD_TRACE_ENABLED") - 1
|| memcmp(cfg->names[0].ptr, "DD_TRACE_ENABLED", sizeof("DD_TRACE_ENABLED") - 1) != 0) { // DD_TRACE_ENABLED is meaningless: always off at rshutdown
if (!cfg->sensitive
&& (cfg->names[0].len != sizeof("DD_TRACE_ENABLED") - 1
|| memcmp(cfg->names[0].ptr, "DD_TRACE_ENABLED", sizeof("DD_TRACE_ENABLED") - 1) != 0)) {
ddog_ConfigurationOrigin origin = DDOG_CONFIGURATION_ORIGIN_ENV_VAR;
switch (cfg->name_index) {
case ZAI_CONFIG_ORIGIN_DEFAULT:
Expand Down
8 changes: 8 additions & 0 deletions loader/tests/functional/test_configuration_telemetry.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
'DD_INJECT_FORCE=true',
'DD_INJECTION_ENABLED=tracer', // Normally set by the injector
'DD_SERVICE=loader',
'DD_API_KEY=SENTINEL_DD_API_KEY',
'DD_VERSION=1.2.3-loader-test',
]);

assertMatchesFormat($output, '%A"loaded_by_ssi":true%s%A');
Expand All @@ -22,3 +24,9 @@
assertContains($content, '{"name":"instrumentation_source","value":"ssi","origin":"default","config_id":null,"seq_id":null}');
assertContains($content, '{"name":"ssi_injection_enabled","value":"tracer","origin":"env_var","config_id":null,"seq_id":null}');
assertContains($content, '{"name":"ssi_forced_injection_enabled","value":"True","origin":"env_var","config_id":null,"seq_id":null}');

assertNotContains($content, 'SENTINEL_DD_API_KEY');
assertNotContains($content, '"name":"DD_API_KEY"');
assertNotContains($content, '"name":"DD_TRACE_ENABLED"');

assertContains($content, '{"name":"DD_VERSION","value":"1.2.3-loader-test","origin":"env_var","config_id":null,"seq_id":null}');
12 changes: 8 additions & 4 deletions metadata/supported-configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
"implementation": "C",
"type": "string",
"default": ""
"default": "",
"sensitive": true
}
],
"DD_API_SECURITY_ENABLED": [
Expand Down Expand Up @@ -2721,7 +2722,8 @@
{
"implementation": "A",
"type": "map",
"default": ""
"default": "",
"sensitive": true
}
],
"OTEL_EXPORTER_OTLP_LOGS_ENDPOINT": [
Expand All @@ -2735,7 +2737,8 @@
{
"implementation": "B",
"type": "map",
"default": null
"default": null,
"sensitive": true
}
],
"OTEL_EXPORTER_OTLP_LOGS_PROTOCOL": [
Expand Down Expand Up @@ -2763,7 +2766,8 @@
{
"implementation": "A",
"type": "map",
"default": null
"default": null,
"sensitive": true
}
],
"OTEL_EXPORTER_OTLP_METRICS_PROTOCOL": [
Expand Down
2 changes: 2 additions & 0 deletions profiling/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ pub struct ZaiConfigEntry {
pub parser: zai_custom_parse,
pub displayer: zai_custom_display,
pub env_config_fallback: zai_env_config_fallback,
pub sensitive: bool,
}

#[repr(C)]
Expand All @@ -717,6 +718,7 @@ pub struct ZaiConfigMemoizedEntry {
pub parser: zai_custom_parse,
pub displayer: zai_custom_display,
pub env_config_fallback: zai_env_config_fallback,
pub sensitive: bool,
pub original_on_modify: Option<
unsafe extern "C" fn(
entry: *mut zend_ini_entry,
Expand Down
24 changes: 24 additions & 0 deletions profiling/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_profiling_enabled),
displayer: Some(display_profiling_enabled),
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingExperimentalFeaturesEnabled),
Expand All @@ -1033,6 +1034,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingEndpointCollectionEnabled),
Expand All @@ -1045,6 +1047,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingExperimentalCpuTimeEnabled),
Expand All @@ -1057,6 +1060,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingAllocationEnabled),
Expand All @@ -1069,6 +1073,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingAllocationSamplingDistance),
Expand All @@ -1081,6 +1086,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_sampling_distance_filter),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingExperimentalHeapLiveEnabled),
Expand All @@ -1093,6 +1099,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingTimelineEnabled),
Expand All @@ -1105,6 +1112,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingExceptionEnabled),
Expand All @@ -1117,6 +1125,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingExceptionMessageEnabled),
Expand All @@ -1129,6 +1138,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingExceptionSamplingDistance),
Expand All @@ -1141,6 +1151,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_sampling_distance_filter),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingExperimentalIOEnabled),
Expand All @@ -1153,6 +1164,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingLogLevel),
Expand All @@ -1165,6 +1177,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_level_filter),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(ProfilingOutputPprof),
Expand All @@ -1177,6 +1190,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
// At the moment, wall-time cannot be fully disabled. This only
// controls automatic collection (manual collection is still
Expand All @@ -1192,6 +1206,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(AgentHost),
Expand All @@ -1204,6 +1219,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(Env),
Expand All @@ -1216,6 +1232,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(Service),
Expand All @@ -1228,6 +1245,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(Tags),
Expand All @@ -1244,6 +1262,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: None,
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(TraceAgentPort),
Expand All @@ -1256,6 +1275,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(TraceAgentUrl),
Expand All @@ -1268,6 +1288,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(Version),
Expand All @@ -1280,6 +1301,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(GitCommitSha),
Expand All @@ -1292,6 +1314,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
zai_config_entry {
id: transmute::<ConfigId, u16>(GitRepositoryUrl),
Expand All @@ -1304,6 +1327,7 @@ pub(crate) fn minit(module_number: libc::c_int) {
parser: Some(parse_utf8_string),
displayer: None,
env_config_fallback: None,
sensitive: false,
},
]
};
Expand Down
12 changes: 8 additions & 4 deletions src/DDTrace/OpenTelemetry/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@
'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT',
'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT',
'OTEL_EXPORTER_OTLP_ENDPOINT',
'OTEL_EXPORTER_OTLP_METRICS_HEADERS',
'OTEL_EXPORTER_OTLP_LOGS_HEADERS',
'OTEL_EXPORTER_OTLP_HEADERS',
'OTEL_EXPORTER_OTLP_METRICS_TIMEOUT',
'OTEL_EXPORTER_OTLP_LOGS_TIMEOUT',
'OTEL_EXPORTER_OTLP_TIMEOUT',
'OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE',
];

const OTEL_SENSITIVE_CONFIGURATIONS = [
'OTEL_EXPORTER_OTLP_HEADERS',
'OTEL_EXPORTER_OTLP_METRICS_HEADERS',
'OTEL_EXPORTER_OTLP_LOGS_HEADERS',
];

// Helper function to track config access
function track_otel_config_if_whitelisted(string $name, $value): void
{
if (in_array($name, OTEL_CONFIG_WHITELIST, true)) {
if (in_array($name, OTEL_CONFIG_WHITELIST, true)
&& !in_array($name, OTEL_SENSITIVE_CONFIGURATIONS, true)) {
// Convert value to string for telemetry
if (is_bool($value)) {
$value_str = $value ? 'true' : 'false';
Expand Down
Loading
Loading