Repository navigation
[RUM-19223] Report each API usage telemetry once per SDK instance - #4037
aleksandr-gringauz wants to merge 5 commits into
Conversation
logApiUsage sent a usage event on every call, so volume scaled with how often apps call the API (e.g. operation steps). Deduplicate each usage type and configuration per SDK instance, before sampling. Ref: RUM-19223 Co-authored-by: aleksandr-gringauz <200633589+aleksandr-gringauz@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| private val onlyOnceMaintainerMessages = mutableSetOf<String>() | ||
| private val onlyOnceTelemetryMessages = mutableSetOf<String>() | ||
|
|
||
| @Suppress("UnsafeThirdPartyFunctionCall") // the argument is always empty |
There was a problem hiding this comment.
don't suppress, put into the yaml detekt config responsible for it
There was a problem hiding this comment.
@aleksandr-gringauz you need to use @\Datadog handle
There was a problem hiding this comment.
There was a problem hiding this comment.
I can only run on private repositories.
There was a problem hiding this comment.
A usage call racing with RUM initialization can permanently suppress that usage’s telemetry, even when later calls occur after initialization completes.
🤖 Bits Code Review · Commit 9cf44db
| val event = apiUsageEventBuilder() | ||
| // Deduplicate before sampling, so that each usage gets a single sampling decision | ||
| // and the effective sample rate remains accurate. | ||
| if (!onlyOnceApiUsages.add(event.onlyOnceKey()) || !sample(samplingRate)) return |
There was a problem hiding this comment.
Wait for telemetry readiness before consuming the usage key
If WebViewTracking.enable races with Rum.enable, a sampled-in TrackWebView event can be dropped after its key is permanently consumed here. DatadogCore.registerFeature exposes RUM before initialization completes, and the global monitor is registered afterward; SdkFeature.sendEvent or the no-op monitor discards events during that interval. Later WebView tracking calls previously could report usage, but now remain suppressed for the SDK instance. Coordinate deduplication with telemetry readiness or buffer the first event; this requires changes across the logger and RUM initialization path.
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
What each reaction means
- 👍 Useful: correct, and you're fixing it or will.
- 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
- 😕 Unclear: you can't tell what it means or why it matters.
- 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.
🤖 Bits Code Review · Open Bits AI session
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: beacc97 | Docs | View more details | Give us feedback! |
Replace the suppressed Collections.newSetFromMap with a ConcurrentHashMap and list its putIfAbsent call as a known safe call. Ref: RUM-19223 Co-authored-by: aleksandr-gringauz <200633589+aleksandr-gringauz@users.noreply.github.com>
Ref: RUM-19223 Co-authored-by: aleksandr-gringauz <200633589+aleksandr-gringauz@users.noreply.github.com>
Keep configuration only for usages that have one; other usages are keyed by type through an else branch. Ref: RUM-19223 Co-authored-by: aleksandr-gringauz <200633589+aleksandr-gringauz@users.noreply.github.com>
| } | ||
|
|
||
| private fun allDistinctApiUsageEvents(): List<InternalTelemetryEvent.ApiUsage> { | ||
| val booleans = listOf(true, false) |
There was a problem hiding this comment.
nit: could be less nested
val addViewLoadingTimeEvents = List(8) { index ->
InternalTelemetryEvent.ApiUsage.AddViewLoadingTime(
overwrite = (index and 0b100) == 0,
noView = (index and 0b010) == 0,
noActiveView = (index and 0b001) == 0
)
}
What does this PR do?
Reporting usage telemetry logs only once so that we don't generate too much unnecessary telemetry.
Motivation
Additional Notes
Testing
Review checklist (to be filled by reviewers)
PR by Bits - View session in Datadog • Open in Slack
Comment @DataDog to request changes