83
83
agentlessURL = "https://instrumentation-telemetry-intake.datadoghq.com/api/v2/apmtelemetry"
84
84
85
85
// defaultHeartbeatInterval is the default interval at which the agent sends a heartbeat.
86
- defaultHeartbeatInterval = time .Minute // seconds
86
+ defaultHeartbeatInterval = time .Minute
87
87
88
88
// defaultExtendedHeartbeatInterval is the default interval at which the agent sends an extended heartbeat.
89
89
defaultExtendedHeartbeatInterval = 24 * time .Hour
@@ -162,12 +162,6 @@ func defaultConfig(config ClientConfig) ClientConfig {
162
162
}
163
163
}
164
164
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
-
171
165
if config .FlushInterval .Min == 0 {
172
166
config .FlushInterval .Min = defaultFlushIntervalRange .Min
173
167
} else {
@@ -180,6 +174,16 @@ func defaultConfig(config ClientConfig) ClientConfig {
180
174
config .FlushInterval .Max = defaultAuthorizedHearbeatRange .Clamp (config .FlushInterval .Max )
181
175
}
182
176
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
+
183
187
if config .DependencyLoader == nil && globalinternal .BoolEnv ("DD_TELEMETRY_DEPENDENCY_COLLECTION_ENABLED" , true ) {
184
188
config .DependencyLoader = debug .ReadBuildInfo
185
189
}
0 commit comments