Skip to content

Commit f1f0df1

Browse files
khanayan123ekump
andauthored
fix(telemetry): wire up DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL to scheduler (#1824)
## Summary Wire up the `DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL` config value to the telemetry scheduler. The env var was already parsed into `config.telemetry_extended_heartbeat_interval` but the scheduler hardcoded `Duration::from_secs(60 * 60 * 24)` instead of using it. Default remains 24h this only enables system tests to use a shorter interval to validate the `app-extended-heartbeat` event fires correctly. ## Changes - **`libdd-telemetry/src/worker/mod.rs`**: Replace hardcoded `60 * 60 * 24` with `config.telemetry_extended_heartbeat_interval` ## Motivation Cross-SDK system tests need to set a short extended heartbeat interval (e.g., 2s) to validate parity of the `app-extended-heartbeat` telemetry event across all SDKs. Without this fix, PHP and other libdatadog consumers cannot be system-tested for this feature. ## Related - System test PR: DataDog/system-tests#6338 Co-authored-by: edmund.kump <edmund.kump@datadoghq.com>
1 parent 0223cd3 commit f1f0df1

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

libdd-telemetry/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ winver = "1.0.0"
4545
[dev-dependencies]
4646
tracing-subscriber = "0.3.22"
4747
tokio = { version = "1.23", features = ["sync", "io-util", "rt-multi-thread"] }
48+
libdd-common = { path = "../libdd-common", features = ["test-utils"] }

libdd-telemetry/src/config.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub struct Config {
2727
/// Enables debug logging
2828
pub telemetry_debug_logging_enabled: bool,
2929
pub telemetry_heartbeat_interval: Duration,
30+
pub telemetry_extended_heartbeat_interval: Duration,
3031
pub direct_submission_enabled: bool,
3132
/// Prevents LifecycleAction::Stop from terminating the worker (except if the WorkerHandle is
3233
/// dropped)
@@ -163,6 +164,7 @@ impl Default for Config {
163164
endpoint: None,
164165
telemetry_debug_logging_enabled: false,
165166
telemetry_heartbeat_interval: Duration::from_secs(60),
167+
telemetry_extended_heartbeat_interval: Duration::from_secs(60 * 60 * 24),
166168
direct_submission_enabled: false,
167169
restartable: false,
168170
debug_enabled: false,
@@ -246,6 +248,7 @@ impl Config {
246248
endpoint: None,
247249
telemetry_debug_logging_enabled: settings.shared_lib_debug,
248250
telemetry_heartbeat_interval: settings.telemetry_heartbeat_interval,
251+
telemetry_extended_heartbeat_interval: settings.telemetry_extended_heartbeat_interval,
249252
direct_submission_enabled: settings.direct_submission_enabled,
250253
restartable: false,
251254
debug_enabled: false,
@@ -473,4 +476,42 @@ mod tests {
473476
.to_string_lossy()
474477
);
475478
}
479+
480+
#[test]
481+
fn test_from_settings_propagates_extended_heartbeat_interval() {
482+
use std::time::Duration;
483+
484+
let custom_interval = Duration::from_secs(120);
485+
let settings = Settings {
486+
telemetry_extended_heartbeat_interval: custom_interval,
487+
..Default::default()
488+
};
489+
let cfg = Config::from_settings(&settings);
490+
assert_eq!(cfg.telemetry_extended_heartbeat_interval, custom_interval);
491+
}
492+
493+
#[test]
494+
fn test_from_settings_default_extended_heartbeat_interval() {
495+
use std::time::Duration;
496+
497+
let settings = Settings::default();
498+
let cfg = Config::from_settings(&settings);
499+
assert_eq!(
500+
cfg.telemetry_extended_heartbeat_interval,
501+
Duration::from_secs(60 * 60 * 24)
502+
);
503+
}
504+
505+
#[test]
506+
fn test_extended_heartbeat_interval_from_env() {
507+
use libdd_common::test_utils::EnvGuard;
508+
use std::time::Duration;
509+
510+
let _guard = EnvGuard::set("DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL", "5");
511+
let settings = Settings::from_env();
512+
assert_eq!(
513+
settings.telemetry_extended_heartbeat_interval,
514+
Duration::from_secs(5)
515+
);
516+
}
476517
}

libdd-telemetry/src/worker/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ impl TelemetryWorkerBuilder {
11081108
let token = CancellationToken::new();
11091109
let config = self.config;
11101110
let telemetry_heartbeat_interval = config.telemetry_heartbeat_interval;
1111+
let telemetry_extended_heartbeat_interval = config.telemetry_extended_heartbeat_interval;
11111112
let client = http_client::from_config(&config);
11121113

11131114
let metrics_flush_interval =
@@ -1140,7 +1141,7 @@ impl TelemetryWorkerBuilder {
11401141
(metrics_flush_interval, LifecycleAction::FlushMetricAggr),
11411142
(telemetry_heartbeat_interval, LifecycleAction::FlushData),
11421143
(
1143-
time::Duration::from_secs(60 * 60 * 24),
1144+
telemetry_extended_heartbeat_interval,
11441145
LifecycleAction::ExtendedHeartbeat,
11451146
),
11461147
]),

0 commit comments

Comments
 (0)