Skip to content
Draft
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
50 changes: 49 additions & 1 deletion datadog-opentelemetry/src/core/configuration/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ pub struct Config {
telemetry_log_collection_enabled: ConfigItem<bool>,
/// Interval by which telemetry events are flushed (seconds)
telemetry_heartbeat_interval: ConfigItem<f64>,
/// Interval by which app-extended-heartbeat events are sent (seconds)
telemetry_extended_heartbeat_interval: ConfigItem<f64>,

/// Partial flush
trace_partial_flush_enabled: ConfigItem<bool>,
Expand Down Expand Up @@ -1183,6 +1185,10 @@ impl Config {
default.telemetry_heartbeat_interval,
|interval: f64| interval.abs(),
),
telemetry_extended_heartbeat_interval: cisu.update_parsed_with_transform(
default.telemetry_extended_heartbeat_interval,
|interval: f64| interval.abs(),
),
trace_propagation_style: cisu
.update_parsed_with_transform(default.trace_propagation_style, |DdTags(tags)| {
TracePropagationStyle::from_tags(Some(tags))
Expand Down Expand Up @@ -1266,6 +1272,7 @@ impl Config {
&self.telemetry_enabled,
&self.telemetry_log_collection_enabled,
&self.telemetry_heartbeat_interval,
&self.telemetry_extended_heartbeat_interval,
&self.trace_partial_flush_enabled,
&self.trace_partial_flush_min_spans,
&self.trace_propagation_style,
Expand Down Expand Up @@ -1449,6 +1456,11 @@ impl Config {
*self.telemetry_heartbeat_interval.value()
}

/// Returns the telemetry extended heartbeat interval in seconds.
pub fn telemetry_extended_heartbeat_interval(&self) -> f64 {
*self.telemetry_extended_heartbeat_interval.value()
}

/// Returns whether OpenTelemetry metrics export is enabled.
pub fn metrics_otel_enabled(&self) -> bool {
*self.metrics_otel_enabled.value()
Expand Down Expand Up @@ -1801,6 +1813,10 @@ fn default_config() -> Config {
SupportedConfigurations::DD_TELEMETRY_HEARTBEAT_INTERVAL,
60.0,
),
telemetry_extended_heartbeat_interval: ConfigItem::new(
SupportedConfigurations::DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL,
86400.0,
),
trace_partial_flush_enabled: ConfigItem::new(
SupportedConfigurations::DD_TRACE_PARTIAL_FLUSH_ENABLED,
false,
Expand Down Expand Up @@ -2039,6 +2055,18 @@ impl ConfigBuilder {
self
}

/// Interval in seconds for sending app-extended-heartbeat telemetry messages.
///
/// **Default**: `86400.0` (24 hours)
///
/// Env variable: `DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL`
pub fn set_telemetry_extended_heartbeat_interval(&mut self, seconds: f64) -> &mut Self {
self.config
.telemetry_extended_heartbeat_interval
.set_code(seconds.abs());
self
}

/// Sets the hostname of the Datadog Agent.
///
/// **Default**: `localhost`
Expand Down Expand Up @@ -3118,6 +3146,24 @@ mod tests {
assert_eq!(config.telemetry_heartbeat_interval(), 42.0);
}

#[test]
fn test_telemetry_extended_heartbeat_config_from_sources() {
let mut sources = CompositeSource::new();
sources.add_source(HashMapSource::from_iter(
[("DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL", "3600")],
ConfigSourceOrigin::EnvVar,
));
let config = Config::builder_with_sources(&sources).build();

assert_eq!(config.telemetry_extended_heartbeat_interval(), 3600.0);
}

#[test]
fn test_telemetry_extended_heartbeat_config_default() {
let config = Config::builder().build();
assert_eq!(config.telemetry_extended_heartbeat_interval(), 86400.0);
}

#[test]
fn test_telemetry_config() {
let mut sources = CompositeSource::new();
Expand All @@ -3134,13 +3180,15 @@ mod tests {
builder
.set_telemetry_enabled(true)
.set_telemetry_log_collection_enabled(true)
.set_telemetry_heartbeat_interval(0.1);
.set_telemetry_heartbeat_interval(0.1)
.set_telemetry_extended_heartbeat_interval(7200.0);

let config = builder.build();

assert!(config.telemetry_enabled());
assert!(config.telemetry_log_collection_enabled());
assert_eq!(config.telemetry_heartbeat_interval(), 0.1);
assert_eq!(config.telemetry_extended_heartbeat_interval(), 7200.0);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) enum SupportedConfigurations {
DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS,
DD_SERVICE,
DD_TAGS,
DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL,
DD_TELEMETRY_HEARTBEAT_INTERVAL,
DD_TELEMETRY_LOG_COLLECTION_ENABLED,
DD_TRACE_AGENT_PORT,
Expand Down Expand Up @@ -93,6 +94,9 @@ impl SupportedConfigurations {
}
SupportedConfigurations::DD_SERVICE => "DD_SERVICE",
SupportedConfigurations::DD_TAGS => "DD_TAGS",
SupportedConfigurations::DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL => {
"DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL"
}
SupportedConfigurations::DD_TELEMETRY_HEARTBEAT_INTERVAL => {
"DD_TELEMETRY_HEARTBEAT_INTERVAL"
}
Expand Down
5 changes: 5 additions & 0 deletions datadog-opentelemetry/src/core/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ fn make_telemetry_worker(
builder.config = libdd_telemetry::config::Config::from_env();
builder.config.telemetry_heartbeat_interval =
Duration::from_secs_f64(config.telemetry_heartbeat_interval());
// Note: telemetry_extended_heartbeat_interval is stored in config but libdd_telemetry v2.0.0
// does not yet support this field. Once libdd_telemetry is updated to support extended heartbeat,
// uncomment the following line:
// builder.config.telemetry_extended_heartbeat_interval =
// Duration::from_secs_f64(config.telemetry_extended_heartbeat_interval());
// builder.config.debug_enabled = true;

builder.run().map(|handle| {
Expand Down
8 changes: 8 additions & 0 deletions supported-configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@
"propertyKeys": ["global_tags"]
}
],
"DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL": [
{
"version": "B",
"type": "decimal",
"default": "86400.0",
"propertyKeys": ["telemetry_extended_heartbeat_interval"]
}
],
"DD_TELEMETRY_HEARTBEAT_INTERVAL": [
{
"version": "B",
Expand Down
Loading