fix: don't report coroutine cancellations as resolve errors in telemetry#242
Merged
fabriziodemaria merged 5 commits intomainfrom May 4, 2026
Merged
fix: don't report coroutine cancellations as resolve errors in telemetry#242fabriziodemaria merged 5 commits intomainfrom
fabriziodemaria merged 5 commits intomainfrom
Conversation
CancellationException was caught by the generic `catch (e: Exception)` branch in RemoteFlagResolver, causing cancelled resolves to be tracked as STATUS_ERROR. This inflated the resolve error ratio significantly because every putContext() / fetchAndActivate() call cancels any in-flight resolve before starting a new one. Skip telemetry tracking entirely for cancelled requests. Also fix pre-existing nullability mismatch in TelemetryTest. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
94c7351 to
4a12a19
Compare
2 tasks
Co-authored-by: Cursor <cursoragent@cursor.com>
ConfidenceError.HttpError extends java.lang.Error, not Exception, so it was bypassing the catch block and being tracked as STATUS_SUCCESS. Add a catch(Error) block so HTTP errors are correctly reported as STATUS_ERROR. Also strengthen test assertions to decode the telemetry header and verify the actual RequestTrace.Status value. Co-authored-by: Cursor <cursoragent@cursor.com>
When the device has no network (DNS resolution fails or there is no route to host), the SDK now reports STATUS_OFFLINE instead of STATUS_ERROR in telemetry. This lets us distinguish genuine errors from expected offline scenarios in metrics. Co-authored-by: Cursor <cursoragent@cursor.com>
nicklasl
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CancellationExceptioninRemoteFlagResolver.resolve()was caught by the genericcatch (e: Exception)branch and tracked asSTATUS_ERRORin telemetry. This inflated theconfidence_sdk_telemetry_resolve_latency_seconds_count{status="STATUS_ERROR"}metric significantly — everyputContext(),fetchAndActivate(), orasyncFetch()call cancels any in-flight resolve before starting a new one, and each cancellation was misreported as an error.STATUS_ERRORwith zero actual network failures. This matches the consistently high error ratios observed in production across all PLATFORM_KOTLIN customers.CancellationExceptionbefore the genericExceptionhandler and skips telemetry tracking entirely for cancelled requests.TelemetryTest.kt(encodedHeaderValue()returnsString?butdecodeMonitoring()expected non-nullString).Test plan
testCancelledResolveDoesNotTrackTelemetry— verifies cancelled resolve produces no telemetry tracetestSuccessfulResolveTracksTelemetry— verifies successful resolve still produces a telemetry tracetestFailedResolveTracksTelemetryAsError— verifies HTTP errors still produce a telemetry traceConfidenceRemoteClientTestsandTelemetryTestpassMade with Cursor