8383 agentlessURL = "https://instrumentation-telemetry-intake.datadoghq.com/api/v2/apmtelemetry"
8484
8585 // defaultHeartbeatInterval is the default interval at which the agent sends a heartbeat.
86- defaultHeartbeatInterval = time .Minute // seconds
86+ defaultHeartbeatInterval = time .Minute
8787
8888 // defaultExtendedHeartbeatInterval is the default interval at which the agent sends an extended heartbeat.
8989 defaultExtendedHeartbeatInterval = 24 * time .Hour
@@ -162,12 +162,6 @@ func defaultConfig(config ClientConfig) ClientConfig {
162162 }
163163 }
164164
165- if config .HeartbeatInterval == 0 {
166- config .HeartbeatInterval = globalinternal .DurationEnv ("DD_TELEMETRY_HEARTBEAT_INTERVAL" , defaultHeartbeatInterval )
167- } else {
168- config .HeartbeatInterval = defaultAuthorizedHearbeatRange .Clamp (config .HeartbeatInterval )
169- }
170-
171165 if config .FlushInterval .Min == 0 {
172166 config .FlushInterval .Min = defaultFlushIntervalRange .Min
173167 } else {
@@ -180,6 +174,16 @@ func defaultConfig(config ClientConfig) ClientConfig {
180174 config .FlushInterval .Max = defaultAuthorizedHearbeatRange .Clamp (config .FlushInterval .Max )
181175 }
182176
177+ heartBeatInterval := defaultHeartbeatInterval
178+ if config .HeartbeatInterval != 0 {
179+ heartBeatInterval = config .HeartbeatInterval
180+ }
181+
182+ envVal := globalinternal .FloatEnv ("DD_TELEMETRY_HEARTBEAT_INTERVAL" , heartBeatInterval .Seconds ())
183+ config .HeartbeatInterval = defaultAuthorizedHearbeatRange .Clamp (time .Duration (envVal * float64 (time .Second )))
184+ // Make sure we flush at least at each heartbeat interval
185+ config .FlushInterval = config .FlushInterval .ReduceMax (config .HeartbeatInterval )
186+
183187 if config .DependencyLoader == nil && globalinternal .BoolEnv ("DD_TELEMETRY_DEPENDENCY_COLLECTION_ENABLED" , true ) {
184188 config .DependencyLoader = debug .ReadBuildInfo
185189 }
0 commit comments