From a257fd383c44781ab1a6fa66b4d8a295521e2542 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Wed, 8 Jan 2025 18:40:27 +0100 Subject: [PATCH] Log time at which heartbeat is sent --- Sources/Sampler.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/Sampler.swift b/Sources/Sampler.swift index 147a6dd..4bffb44 100644 --- a/Sources/Sampler.swift +++ b/Sources/Sampler.swift @@ -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