Conversation
507631d to
ae2eb42
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a profiling/telemetry system to the Radar SDK to measure execution times of various operations during location tracking.
- Adds a new
RadarTelemetryclass for timing operations - Integrates telemetry timing calls throughout the verification tracking flow
- Updates imports to be more explicit rather than using wildcard imports
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| RadarTelemetry.kt | New telemetry class that tracks start/end times for operations and formats timing data |
| RadarVerificationManager.kt | Adds telemetry timing to track verification flow stages including config retrieval, location getting, integrity tokens, and API calls |
| Radar.kt | Integrates telemetry into the trackOnce method and replaces wildcard imports with explicit imports |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| fun formatted(): String { | ||
| return endTimes.map { (tag, endTime) -> | ||
| val diff = endTime - startTimes[tag]!! | ||
| "${tag}: ${"%.2f".format(diff.toFloat() / 1000)}s" |
There was a problem hiding this comment.
Force unwrapping with !! could cause a crash if endTimes contains a tag that's not in startTimes. This could happen if end() is called without a corresponding start() call. Consider using safe access or validation.
| "${tag}: ${"%.2f".format(diff.toFloat() / 1000)}s" | |
| return endTimes.mapNotNull { (tag, endTime) -> | |
| val startTime = startTimes[tag] | |
| if (startTime != null) { | |
| val diff = endTime - startTime | |
| "${tag}: ${"%.2f".format(diff.toFloat() / 1000)}s" | |
| } else { | |
| null | |
| } |
|
|
||
| fun end(tag: String = "") { | ||
| if (startTimes.containsKey(tag)) { | ||
| endTimes[tag] = Date().time |
There was a problem hiding this comment.
Using Date().time creates unnecessary Date objects. Consider using System.currentTimeMillis() which is more efficient for timing measurements.
| endTimes[tag] = Date().time | |
| class RadarTelemetry { | |
| private val startTimes: MutableMap<String, Long> = mutableMapOf() | |
| private val endTimes: MutableMap<String, Long> = mutableMapOf() | |
| fun start(tag: String = "") { | |
| startTimes[tag] = System.currentTimeMillis() | |
| } | |
| fun end(tag: String = "") { | |
| if (startTimes.containsKey(tag)) { | |
| endTimes[tag] = System.currentTimeMillis() |
|
|
||
| fun end(tag: String = "") { | ||
| if (startTimes.containsKey(tag)) { | ||
| endTimes[tag] = Date().time |
There was a problem hiding this comment.
Using Date().time creates unnecessary Date objects. Consider using System.currentTimeMillis() which is more efficient for timing measurements.
| endTimes[tag] = Date().time | |
| startTimes[tag] = System.currentTimeMillis() | |
| } | |
| fun end(tag: String = "") { | |
| if (startTimes.containsKey(tag)) { | |
| endTimes[tag] = System.currentTimeMillis() |
| package io.radar.sdk | ||
|
|
||
| import java.util.Date | ||
|
|
There was a problem hiding this comment.
Public class lacks documentation. Consider adding KDoc to explain the purpose and usage of this telemetry class.
| /** | |
| * RadarTelemetry provides simple timing utilities for measuring the duration of code execution. | |
| * | |
| * Usage: | |
| * - Call [start] with an optional tag to begin timing. | |
| * - Call [end] with the same tag to end timing. | |
| * - Use [get] to retrieve the elapsed time in milliseconds for a tag. | |
| * - Use [formatted] to get a human-readable summary of all timings. | |
| * | |
| * This class is useful for performance monitoring and debugging. | |
| */ |
No description provided.