Skip to content

Commit d497c8d

Browse files
feat: No longer launch Go-based agent for compatibility/OTLP/AAP config (#788)
https://datadoghq.atlassian.net/browse/SVLS-7398 - As part of coming release, bottlecap agent no longer launches Go-based agent when compatibility/AAP/OTLP features are active - Emit the same metric when detecting any of above configuration - Update corresponding unit tests - Refactor the references of enhanced metrics. Manifests: - [Test lambda function](https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions/ltn1-fullinstrument-bn-cold-python310-lambda?code=&subtab=envVars&tab=testing) with [logs](https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#logsV2:log-groups/log-group/$252Faws$252Flambda$252Fltn1-fullinstrument-bn-cold-python310-lambda/log-events/2025$252F08$252F21$252F$255B$2524LATEST$255Df3788d359677452dad162488ff15456f$3FfilterPattern$3Dotel) showing compatibility/AAP/OTPL are enabled <img width="2260" height="454" alt="image" src="https://github.com/user-attachments/assets/5dfd4954-5191-4390-83f5-a8eb3bffb9d3" /> - [Logging](https://app.datadoghq.com/logs/livetail?query=functionname%3Altn1-fullinstrument-bn-cold-python310-lambda%20Metric&agg_m=count&agg_m_source=base&agg_t=count&cols=host%2Cservice&fromUser=true&messageDisplay=inline&refresh_mode=paused&storage=driveline&stream_sort=desc&viz=stream&from_ts=1755787655569&to_ts=1755787689060&live=false) <img width="1058" height="911" alt="image" src="https://github.com/user-attachments/assets/629f75d1-e115-4478-afac-ad16d9369fa7" /> - [Metric](https://app.datadoghq.com/screen/integration/aws_lambda_enhanced_metrics?fromUser=false&fullscreen_end_ts=1755788220000&fullscreen_paused=true&fullscreen_refresh_mode=paused&fullscreen_section=overview&fullscreen_start_ts=1755787200000&fullscreen_widget=2&graph-explorer__tile_def=N4IgbglgXiBcIBcD2AHANhAzgkAaEAxgK7ZIC2A%2BhgHYDWmcA2gLr4BOApgI5EfYOxGoTphRJqmDhQBmSNmQCGOeJgIK0CtnhA8ObCHyagAJkoUVMSImwIc4IMhwT6CDfNQWP7utgE8AjNo%2BvvaYRGSwpggKxkgA5gB0kmxgemh8mAkcAB4IHBIQ4gnSChBoSKlswAAkCgDumBQKBARW1Ai41ZxxhdSd0kTUBAi9AL4ABABGvuPAA0Mj4h6OowkKja2DCAAUAJTaCnFx3UpyoeEgo6wgsvJEGgJCN3Jk9wrevH6BV-iWbMqgTbtOAAJgADPg5MY9BRpkZEL4UHZ4LdXhptBBqNDsnAISAoXp7NDVJdmKMfiBsL50nBgOSgA&refresh_mode=sliding&from_ts=1755783890661&to_ts=1755787490661&live=true) <img width="1227" height="1196" alt="image" src="https://github.com/user-attachments/assets/2922eb54-9853-4512-a902-dfa97916b643" />
1 parent 5f30e76 commit d497c8d

File tree

2 files changed

+92
-20
lines changed

2 files changed

+92
-20
lines changed

bottlecap/src/bin/bottlecap/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ async fn extension_loop_active(
515515
enhanced_metrics::new(metrics_aggr_handle.clone(), Arc::clone(config));
516516

517517
// Send config issue metrics
518-
let config_issues = config::fallback(config);
518+
let config_issues = config::inspect_config(config);
519519
send_config_issue_metric(&config_issues, &lambda_enhanced_metrics);
520520

521521
let propagator = Arc::new(DatadogCompositePropagator::new(Arc::clone(config)));

bottlecap/src/config/mod.rs

Lines changed: 91 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,12 @@ impl Default for Config {
441441
}
442442
}
443443

444-
fn log_fallback_reason(reason: &str) {
444+
fn log_unsupported_reason(reason: &str) {
445445
error!("Fallback support for {reason} is no longer available.");
446446
}
447447

448448
#[must_use = "fallback reasons should be processed to emit appropriate metrics"]
449-
pub fn fallback(config: &Config) -> Vec<String> {
449+
pub fn inspect_config(config: &Config) -> Vec<String> {
450450
let mut fallback_reasons = Vec::new();
451451

452452
// Customer explicitly opted out of the Next Gen extension
@@ -458,15 +458,15 @@ pub fn fallback(config: &Config) -> Vec<String> {
458458

459459
if opted_out {
460460
let reason = "extension_version";
461-
log_fallback_reason(reason);
461+
log_unsupported_reason(reason);
462462
fallback_reasons.push(reason.to_string());
463463
}
464464

465465
// ASM / .NET
466466
// todo(duncanista): Remove once the .NET runtime is fixed
467467
if config.serverless_appsec_enabled && has_dotnet_binary() {
468468
let reason = "serverless_appsec_enabled_dotnet";
469-
log_fallback_reason(reason);
469+
log_unsupported_reason(reason);
470470
fallback_reasons.push(reason.to_string());
471471
}
472472
// OTLP
@@ -501,7 +501,7 @@ pub fn fallback(config: &Config) -> Vec<String> {
501501

502502
if has_otlp_config {
503503
let reason = "otel";
504-
log_fallback_reason(reason);
504+
log_unsupported_reason(reason);
505505
fallback_reasons.push(reason.to_string());
506506
}
507507

@@ -724,15 +724,98 @@ pub mod tests {
724724
};
725725

726726
#[test]
727-
fn test_reject_on_opted_out() {
727+
fn test_baseline_case() {
728728
figment::Jail::expect_with(|jail| {
729729
jail.clear_env();
730-
jail.set_env("DD_EXTENSION_VERSION", "compatibility");
731730
let _config = get_config(Path::new(""));
732731
Ok(())
733732
});
734733
}
735734

735+
#[test]
736+
fn test_inspect_config() {
737+
struct TestCase {
738+
name: &'static str,
739+
env_vars: Vec<(&'static str, &'static str)>,
740+
yaml_content: Option<&'static str>,
741+
expected_reasons: Vec<&'static str>,
742+
}
743+
744+
let test_cases = vec![
745+
TestCase {
746+
name: "default config - no fallback reasons",
747+
env_vars: vec![],
748+
yaml_content: None,
749+
expected_reasons: vec![],
750+
},
751+
TestCase {
752+
name: "extension_version compatibility - should fallback",
753+
env_vars: vec![("DD_EXTENSION_VERSION", "compatibility")],
754+
yaml_content: None,
755+
expected_reasons: vec!["extension_version"],
756+
},
757+
TestCase {
758+
name: "otlp config enabled - should fallback",
759+
env_vars: vec![(
760+
"DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_ENDPOINT",
761+
"localhost:4317",
762+
)],
763+
yaml_content: None,
764+
expected_reasons: vec!["otel"],
765+
},
766+
TestCase {
767+
name: "multiple fallback reasons",
768+
env_vars: vec![
769+
("DD_EXTENSION_VERSION", "compatibility"),
770+
("DD_OTLP_CONFIG_METRICS_ENABLED", "true"),
771+
],
772+
yaml_content: None,
773+
expected_reasons: vec!["extension_version", "otel"],
774+
},
775+
TestCase {
776+
name: "otlp config via yaml - should fallback",
777+
env_vars: vec![],
778+
yaml_content: Some(
779+
r"
780+
otlp_config:
781+
receiver:
782+
protocols:
783+
grpc:
784+
endpoint: localhost:4317
785+
",
786+
),
787+
expected_reasons: vec!["otel"],
788+
},
789+
];
790+
791+
for test_case in test_cases {
792+
figment::Jail::expect_with(|jail| {
793+
jail.clear_env();
794+
795+
// Set environment variables
796+
for (key, value) in &test_case.env_vars {
797+
jail.set_env(key, value);
798+
}
799+
800+
// Create YAML file if provided
801+
if let Some(yaml_content) = test_case.yaml_content {
802+
jail.create_file("datadog.yaml", yaml_content)?;
803+
}
804+
805+
let config = get_config(Path::new(""));
806+
let fallback_reasons = inspect_config(&config);
807+
808+
assert_eq!(
809+
fallback_reasons, test_case.expected_reasons,
810+
"Test case '{}' failed: expected {:?}, got {:?}",
811+
test_case.name, test_case.expected_reasons, fallback_reasons
812+
);
813+
814+
Ok(())
815+
});
816+
}
817+
}
818+
736819
#[test]
737820
fn test_fallback_on_otel() {
738821
figment::Jail::expect_with(|jail| {
@@ -849,17 +932,6 @@ pub mod tests {
849932
});
850933
}
851934

852-
#[test]
853-
fn test_allowed_but_disabled() {
854-
figment::Jail::expect_with(|jail| {
855-
jail.clear_env();
856-
jail.set_env("DD_SERVERLESS_APPSEC_ENABLED", "true");
857-
858-
let _config = get_config(Path::new(""));
859-
Ok(())
860-
});
861-
}
862-
863935
#[test]
864936
fn test_precedence() {
865937
figment::Jail::expect_with(|jail| {
@@ -871,7 +943,7 @@ pub mod tests {
871943
",
872944
)?;
873945
jail.set_env("DD_SITE", "datad0g.com");
874-
let config = get_config(Path::new(""));
946+
let config = get_config(Path::new("")).expect("should parse config");
875947
assert_eq!(config.site, "datad0g.com");
876948
Ok(())
877949
});

0 commit comments

Comments
 (0)