Skip to content

Commit

Permalink
Log time at which heartbeat is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Jan 8, 2025
1 parent f603a1b commit a257fd3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Sources/Sampler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,20 @@ class Sampler {
os_log("No accumulator found for %s, skipping sendHeartbeat", log: OSLog.tracker, type:.debug, key)
return
}
let now = Date()
let incSecs: TimeInterval = trackedData.accumulatedTime
if incSecs > 0 {
os_log("Sending heartbeat for %s", log: OSLog.tracker, type:.debug, key)
os_log(
"Sending heartbeat for %s. Timestamp: %s.",
log: OSLog.tracker,
type:.debug,
key,
now.description
)
heartbeatFn(data: trackedData, enableHeartbeats: true)
}
trackedData.accumulatedTime = 0
let totalTrackedTime: TimeInterval = Date().timeIntervalSince(trackedData.firstSampleTime!)
let totalTrackedTime: TimeInterval = now.timeIntervalSince(trackedData.firstSampleTime!)
trackedData.heartbeatTimeout = getHeartbeatInterval(
existingTimeout: trackedData.heartbeatTimeout!,
totalTrackedTime: totalTrackedTime
Expand Down

0 comments on commit a257fd3

Please sign in to comment.