Skip to content

fix(proxy): fire telemetry row for usage-bypass turns#729

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1752601500-bypass-telemetry2
Open

fix(proxy): fire telemetry row for usage-bypass turns#729
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1752601500-bypass-telemetry2

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Usage-bypass turns (bypassToAnthropic) recorded an otel span but never called s.fireTelemetry, so subscription-served turns were invisible in the dashboard's metrics, model distribution, and cost charts. bypassToAnthropic now takes turnType/routeMs and fires an InsertTelemetryParams row 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 upstreamStatusCode before the buffered *UpstreamErrorResponse flush clears proxyErr, 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

Adapted from #517 by @jperla

Co-Authored-By: Steven Tohme <steven@workweave.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown

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>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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),
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Triggered by learned rule: Telemetry params must be populated at all fireTelemetry call sites

Reviewed by Cursor Bugbot for commit b20e2ba. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants