Skip to content

Commit 44c12db

Browse files
RUM-13949 fix start/end timestamp bug and strip debug logging from TimeseriesSessionCollector
1 parent 90c7795 commit 44c12db

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/timeseries/TimeseriesSessionCollector.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ internal class TimeseriesSessionCollector(
4747

4848
private val memoryBuffer = mutableListOf<RumTimeseriesMemoryEvent.Data>()
4949
private val cpuBuffer = mutableListOf<RumTimeseriesCpuEvent.Data>()
50-
private var batchStartNs: Long = 0L
5150

5251
private var prevCpuTicks: Long = 0L
5352
private val cpuClockTicks: Long = Os.sysconf(OsConstants._SC_CLK_TCK)
@@ -59,7 +58,6 @@ internal class TimeseriesSessionCollector(
5958
synchronized(this) {
6059
memoryBuffer.clear()
6160
cpuBuffer.clear()
62-
batchStartNs = System.nanoTime()
6361
}
6462
prevCpuTicks = readCpuTicks()
6563

@@ -93,7 +91,6 @@ internal class TimeseriesSessionCollector(
9391
if (memoryBuffer.size >= batchSize) {
9492
flushMemoryBatch()
9593
memoryBuffer.clear()
96-
batchStartNs = System.nanoTime()
9794
}
9895
if (cpuBuffer.size >= batchSize) {
9996
flushCpuBatch()
@@ -127,12 +124,13 @@ internal class TimeseriesSessionCollector(
127124

128125
private fun flushMemoryBatch() {
129126
if (memoryBuffer.isEmpty()) return
130-
val startNs = batchStartNs
127+
val startNs = memoryBuffer.first().timestamp
131128
val endNs = memoryBuffer.last().timestamp
132129
val data = memoryBuffer.toList()
133130
val currentSessionId = sessionId
134131
val currentApplicationId = applicationId
135132
val currentSessionType = sessionType
133+
136134
sdkCore.getFeature(Feature.RUM_FEATURE_NAME)?.withWriteContext { datadogContext, writeScope ->
137135
val event = RumTimeseriesMemoryEvent(
138136
dd = RumTimeseriesMemoryEvent.Dd(),
@@ -161,12 +159,13 @@ internal class TimeseriesSessionCollector(
161159

162160
private fun flushCpuBatch() {
163161
if (cpuBuffer.isEmpty()) return
164-
val startNs = batchStartNs
162+
val startNs = cpuBuffer.first().timestamp
165163
val endNs = cpuBuffer.last().timestamp
166164
val data = cpuBuffer.toList()
167165
val currentSessionId = sessionId
168166
val currentApplicationId = applicationId
169167
val currentSessionType = sessionType
168+
170169
sdkCore.getFeature(Feature.RUM_FEATURE_NAME)?.withWriteContext { datadogContext, writeScope ->
171170
val event = RumTimeseriesCpuEvent(
172171
dd = RumTimeseriesCpuEvent.Dd(),

0 commit comments

Comments
 (0)