Skip to content
Merged
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
33 changes: 33 additions & 0 deletions bottlecap/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ use crate::config::service_mapping::deserialize_service_mapping;
#[derive(Debug, PartialEq, Deserialize, Clone, Default)]
#[serde(default)]
#[allow(clippy::module_name_repetitions)]
#[allow(clippy::struct_excessive_bools)]
pub struct FallbackConfig {
extension_version: Option<String>,
serverless_appsec_enabled: bool,
appsec_enabled: bool,
profiling_enabled: bool,
// otel
trace_otel_enabled: bool,
otlp_config_receiver_protocols_http_endpoint: Option<String>,
otlp_config_receiver_protocols_grpc_endpoint: Option<String>,
}

#[derive(Debug, PartialEq, Deserialize, Clone, Default)]
Expand Down Expand Up @@ -165,6 +170,18 @@ fn fallback(figment: &Figment) -> Result<(), ConfigError> {
));
}

if fallback_config.trace_otel_enabled
|| fallback_config
.otlp_config_receiver_protocols_http_endpoint
.is_some()
|| fallback_config
.otlp_config_receiver_protocols_grpc_endpoint
.is_some()
{
log_fallback_reason("otel");
return Err(ConfigError::UnsupportedField("otel".to_string()));
}

Ok(())
}

Expand Down Expand Up @@ -255,6 +272,22 @@ pub mod tests {
});
}

#[test]
fn test_fallback_on_otel() {
figment::Jail::expect_with(|jail| {
jail.clear_env();
jail.set_env("DD_EXTENSION_VERSION", "next");
jail.set_env(
"DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_HTTP_ENDPOINT",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a complementary DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_ENDPOINT we should probably listen for as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its in the config file as fallback too

"localhost:4138",
);

let config = get_config(Path::new("")).expect_err("should reject unknown fields");
assert_eq!(config, ConfigError::UnsupportedField("otel".to_string()));
Ok(())
});
}

#[test]
fn test_allowed_but_disabled() {
figment::Jail::expect_with(|jail| {
Expand Down
Loading