Skip to content

Commit ae3e674

Browse files
authored
chore: [Trace Stats] Rename env var DD_COMPUTE_TRACE_STATS (#875)
# This PR As @apiarian-datadog suggested in #841 (comment), rename the feature flag `DD_COMPUTE_TRACE_STATS` to `DD_COMPUTE_TRACE_STATS_ON_EXTENSION` for clarity. # Notes Jira: https://datadoghq.atlassian.net/browse/SVLS-7593
1 parent 1dfdaa9 commit ae3e674

6 files changed

Lines changed: 17 additions & 17 deletions

File tree

bottlecap/src/config/env.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,13 @@ pub struct EnvConfig {
358358
/// The maximum depth of the Lambda payload to capture.
359359
/// Default is `10`. Requires `capture_lambda_payload` to be `true`.
360360
pub capture_lambda_payload_max_depth: Option<u32>,
361-
/// @env `DD_COMPUTE_TRACE_STATS`
361+
/// @env `DD_COMPUTE_TRACE_STATS_ON_EXTENSION`
362362
///
363363
/// If true, enable computation of trace stats on the extension side.
364364
/// If false, trace stats will be computed on the backend side.
365365
/// Default is `false`.
366366
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
367-
pub compute_trace_stats: Option<bool>,
367+
pub compute_trace_stats_on_extension: Option<bool>,
368368
/// @env `DD_SERVERLESS_APPSEC_ENABLED`
369369
///
370370
/// Enable Application and API Protection (AAP), previously known as AppSec/ASM, for AWS Lambda.
@@ -571,7 +571,7 @@ fn merge_config(config: &mut Config, env_config: &EnvConfig) {
571571
merge_option_to_value!(config, env_config, lambda_proc_enhanced_metrics);
572572
merge_option_to_value!(config, env_config, capture_lambda_payload);
573573
merge_option_to_value!(config, env_config, capture_lambda_payload_max_depth);
574-
merge_option_to_value!(config, env_config, compute_trace_stats);
574+
merge_option_to_value!(config, env_config, compute_trace_stats_on_extension);
575575
merge_option_to_value!(config, env_config, serverless_appsec_enabled);
576576
merge_option!(config, env_config, appsec_rules);
577577
merge_option_to_value!(config, env_config, appsec_waf_timeout);
@@ -765,7 +765,7 @@ mod tests {
765765
jail.set_env("DD_LAMBDA_PROC_ENHANCED_METRICS", "false");
766766
jail.set_env("DD_CAPTURE_LAMBDA_PAYLOAD", "true");
767767
jail.set_env("DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH", "5");
768-
jail.set_env("DD_COMPUTE_TRACE_STATS", "true");
768+
jail.set_env("DD_COMPUTE_TRACE_STATS_ON_EXTENSION", "true");
769769
jail.set_env("DD_SERVERLESS_APPSEC_ENABLED", "true");
770770
jail.set_env("DD_APPSEC_RULES", "/path/to/rules.json");
771771
jail.set_env("DD_APPSEC_WAF_TIMEOUT", "1000000"); // Microseconds
@@ -915,7 +915,7 @@ mod tests {
915915
lambda_proc_enhanced_metrics: false,
916916
capture_lambda_payload: true,
917917
capture_lambda_payload_max_depth: 5,
918-
compute_trace_stats: true,
918+
compute_trace_stats_on_extension: true,
919919
serverless_appsec_enabled: true,
920920
appsec_rules: Some("/path/to/rules.json".to_string()),
921921
appsec_waf_timeout: Duration::from_secs(1),

bottlecap/src/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ pub struct Config {
343343
pub lambda_proc_enhanced_metrics: bool,
344344
pub capture_lambda_payload: bool,
345345
pub capture_lambda_payload_max_depth: u32,
346-
pub compute_trace_stats: bool,
346+
pub compute_trace_stats_on_extension: bool,
347347

348348
pub serverless_appsec_enabled: bool,
349349
pub appsec_rules: Option<String>,
@@ -446,7 +446,7 @@ impl Default for Config {
446446
lambda_proc_enhanced_metrics: true,
447447
capture_lambda_payload: false,
448448
capture_lambda_payload_max_depth: 10,
449-
compute_trace_stats: false,
449+
compute_trace_stats_on_extension: false,
450450

451451
serverless_appsec_enabled: false,
452452
appsec_rules: None,

bottlecap/src/config/yaml.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct YamlConfig {
9999
pub capture_lambda_payload: Option<bool>,
100100
pub capture_lambda_payload_max_depth: Option<u32>,
101101
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
102-
pub compute_trace_stats: Option<bool>,
102+
pub compute_trace_stats_on_extension: Option<bool>,
103103
#[serde(deserialize_with = "deserialize_optional_bool_from_anything")]
104104
pub serverless_appsec_enabled: Option<bool>,
105105
pub appsec_rules: Option<String>,
@@ -656,7 +656,7 @@ fn merge_config(config: &mut Config, yaml_config: &YamlConfig) {
656656
merge_option_to_value!(config, yaml_config, lambda_proc_enhanced_metrics);
657657
merge_option_to_value!(config, yaml_config, capture_lambda_payload);
658658
merge_option_to_value!(config, yaml_config, capture_lambda_payload_max_depth);
659-
merge_option_to_value!(config, yaml_config, compute_trace_stats);
659+
merge_option_to_value!(config, yaml_config, compute_trace_stats_on_extension);
660660
merge_option_to_value!(config, yaml_config, serverless_appsec_enabled);
661661
merge_option!(config, yaml_config, appsec_rules);
662662
merge_option_to_value!(config, yaml_config, appsec_waf_timeout);
@@ -826,7 +826,7 @@ enhanced_metrics: false
826826
lambda_proc_enhanced_metrics: false
827827
capture_lambda_payload: true
828828
capture_lambda_payload_max_depth: 5
829-
compute_trace_stats: true
829+
compute_trace_stats_on_extension: true
830830
serverless_appsec_enabled: true
831831
appsec_rules: "/path/to/rules.json"
832832
appsec_waf_timeout: 1000000 # Microseconds
@@ -959,7 +959,7 @@ extension_version: "compatibility"
959959
lambda_proc_enhanced_metrics: false,
960960
capture_lambda_payload: true,
961961
capture_lambda_payload_max_depth: 5,
962-
compute_trace_stats: true,
962+
compute_trace_stats_on_extension: true,
963963

964964
serverless_appsec_enabled: true,
965965
appsec_rules: Some("/path/to/rules.json".to_string()),

bottlecap/src/otlp/agent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl Agent {
173173
.into_response();
174174
}
175175

176-
let compute_trace_stats = config.compute_trace_stats;
176+
let compute_trace_stats_on_extension = config.compute_trace_stats_on_extension;
177177
let (send_data_builder, processed_traces) = trace_processor.process_traces(
178178
config,
179179
tags_provider,
@@ -198,7 +198,7 @@ impl Agent {
198198

199199
// This needs to be after process_traces() because process_traces()
200200
// performs obfuscation, and we need to compute stats on the obfuscated traces.
201-
if compute_trace_stats {
201+
if compute_trace_stats_on_extension {
202202
if let Err(err) = stats_generator.send(&processed_traces) {
203203
// Just log the error. We don't think trace stats are critical, so we don't want to
204204
// return an error if only stats fail to send.

bottlecap/src/tags/lambda/tags.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ fn tags_from_env(
127127
tags_map.extend(config.tags.clone());
128128
}
129129

130-
// The value of _dd.compute_stats is the opposite of config.compute_trace_stats.
131-
// "config.compute_trace_stats == true" means computing stats on the extension side,
130+
// The value of _dd.compute_stats is the opposite of config.compute_trace_stats_on_extension.
131+
// "config.compute_trace_stats_on_extension == true" means computing stats on the extension side,
132132
// so we set _dd.compute_stats to 0 so stats won't be computed on the backend side.
133-
let compute_stats = i32::from(!config.compute_trace_stats);
133+
let compute_stats = i32::from(!config.compute_trace_stats_on_extension);
134134
tags_map.insert(COMPUTE_STATS_KEY.to_string(), compute_stats.to_string());
135135

136136
tags_map

bottlecap/src/traces/trace_processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl SendingTraceProcessor {
461461

462462
// This needs to be after process_traces() because process_traces()
463463
// performs obfuscation, and we need to compute stats on the obfuscated traces.
464-
if config.compute_trace_stats {
464+
if config.compute_trace_stats_on_extension {
465465
if let Err(err) = self.stats_generator.send(&processed_traces) {
466466
// Just log the error. We don't think trace stats are critical, so we don't want to
467467
// return an error if only stats fail to send.

0 commit comments

Comments
 (0)