Support legacy gen_ai token usage attributes#19
Open
haasonsaas wants to merge 1 commit into
Open
Conversation
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
Workshop currently drops token counts from the
raindrop-aicore-SDK instrumentation path because the producer and consumer disagree on thegen_ai.*token attribute names.This change teaches
parseOtlpRequestto read the legacy OpenLLMetry names in addition to the newer OTel semantic convention names:gen_ai.usage.prompt_tokensgen_ai.usage.completion_tokensThe existing Vercel AI SDK and new-semconv paths stay first in the lookup order, so this is additive for paths that already work.
Root cause
raindrop-aibundles OpenLLMetry instrumentations such as@traceloop/instrumentation-openai@0.19.0-otel-v1and the matching Anthropic, Bedrock, Cohere, Vertex, Together, etc. instrumentations. Those emit the legacy token attributes:Workshop ingest only read the newer OTel GenAI semantic convention names for
gen_ai.*usage, plus Vercel AI SDK'sai.usage.*attributes:That means spans from the core-SDK
instrumentModulespath landed withnull/ missinginput_tokensandoutput_tokens, so Workshop could not show per-call or per-run token/cost data. The AI SDK path was unaffected because it emitsai.usage.*, which Workshop already handled.Fix
Append the legacy OpenLLMetry keys to the parser fallback lists:
first()returns the first attribute that exists, so appending these names preserves the current precedence for AI SDK and new-semconv spans.Validation
bun test tests/passes locally.bun run buildpasses locally, including migration embed check,tsc --noEmit, and the Vite UI build.tests/parse.test.tscovering the legacy OpenLLMetry attribute pair.