This is a submission for DEV's Summer Bug Smash: Clear the Lineup powered by Sentry.

The bug

Sentry's JavaScript SDK auto-instruments the Vercel AI SDK, so every generateText or streamText call shows up as a gen_ai span with token usage attached. When the model is a Gemini reasoning model, that usage was wrong: the span undercounted the output and the total because it silently dropped Gemini's reasoning tokens.

Gemini reports its reasoning ("thoughts") tokens separately from the visible answer. The AI SDK's outputTokens covers only the candidate answer and exposes the reasoning count through providerMetadata.google.usageMetadata.thoughtsTokenCount. Sentry's getProviderMetadataAttributes() handled OpenAI, Anthropic, Bedrock and DeepSeek metadata, but it never looked at the Google or Vertex block, so the reasoning tokens vanished from the span and the total was computed as input plus candidate-only output.

On a real Gemini call this is not a rounding error. The model returned usageMetadata { promptTokenCount: 14, candidatesTokenCount: 1, thoughtsTokenCount: 100, totalTokenCount: 115 }. Sentry recorded output_tokens: 1 and total_tokens: 15, hiding 100 reasoning tokens. For a reasoning model the reasoning tokens are most of the cost, so the trace understated real usage by nearly 8x.