fix(proxy): fire telemetry row for usage-bypass turns#729
fix(proxy): fire telemetry row for usage-bypass turns#729devin-ai-integration[bot] wants to merge 2 commits into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
PR author is not in the allowed authors list. |
Co-authored-by: Rohith Reddy Nama <104615697+rohith500@users.noreply.github.com> Co-Authored-By: Steven Tohme <steven@workweave.ai>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b20e2ba. Configure here.
| TurnType: turnType, | ||
| CacheCreationTokens: cacheTokenPtr(cacheCreation), | ||
| CacheReadTokens: cacheTokenPtr(cacheRead), | ||
| }) |
There was a problem hiding this comment.
Bypass telemetry omits credential attribution
Medium Severity
The new fireTelemetry block for usage-bypass turns does not set CredentialKeyPrefix, CredentialKeySuffix, or CredentialSource, unlike the routed ProxyMessages and ProxyOpenAIChatCompletion upstream rows. These turns always run on the caller’s subscription credential after resolveAndInjectCredentials, so the row leaves attribution NULL and breaks parity with other subscription-served telemetry.
Additional Locations (1)
Triggered by learned rule: Telemetry params must be populated at all fireTelemetry call sites
Reviewed by Cursor Bugbot for commit b20e2ba. Configure here.


Summary
Usage-bypass turns (
bypassToAnthropic) recorded an otel span but never calleds.fireTelemetry, so subscription-served turns were invisible in the dashboard's metrics, model distribution, and cost charts.bypassToAnthropicnow takesturnType/routeMsand fires anInsertTelemetryParamsrow after the otel record, reusing the extractor's real token counts and computed costs (unlike a routed turn, requested == actual since bypass never substitutes).The upstream status is captured into
upstreamStatusCodebefore the buffered*UpstreamErrorResponseflush clearsproxyErr, so error turns keep their real status in telemetry. The retryable-error path (errBypassRetryable) returns before telemetry — the rerouted dispatch fires its own row.Adapted from #517 by @jperla (thank you!) — rebased onto the current bypass code (usage extractor, retryable reroute) and wired real token/cost values into the row instead of zeros.
Link to Devin session: https://app.devin.ai/sessions/840868be330a4e258f7325867c84caaf
Requested by: @steventohme