Summary
The ADK (trace/contrib/adk) integration records token usage as raw OpenTelemetry semantic-convention attributes (gen_ai.usage.prompt_tokens, gen_ai.usage.completion_tokens, gen_ai.usage.total_tokens) instead of the braintrust.metrics JSON blob that the Braintrust platform expects. It also never sets braintrust.metadata (model name, temperature, etc.) or time_to_first_token. This means ADK model-call spans are invisible to Braintrust's token-usage dashboards, cost tracking, and metadata filters.
Current behaviour
In trace/contrib/adk/traceadk.go lines 379-388, the AfterModel callback sets token counts as individual OTel attributes:
if resp.UsageMetadata != nil {
if resp.UsageMetadata.PromptTokenCount > 0 {
span.SetAttributes(attribute.Int64("gen_ai.usage.prompt_tokens", int64(resp.UsageMetadata.PromptTokenCount)))
}
if resp.UsageMetadata.CandidatesTokenCount > 0 {
span.SetAttributes(attribute.Int64("gen_ai.usage.completion_tokens", int64(resp.UsageMetadata.CandidatesTokenCount)))
}
if resp.UsageMetadata.TotalTokenCount > 0 {
span.SetAttributes(attribute.Int64("gen_ai.usage.total_tokens", int64(resp.UsageMetadata.TotalTokenCount)))
}
}
No braintrust.metadata attribute is ever set.
Expected behaviour
Token usage should be serialised into a braintrust.metrics JSON attribute (matching the pattern used by every other integration — OpenAI, Anthropic, GenAI, Bedrock, Genkit, Eino, LangChainGo):
{
"prompt_tokens": 100,
"completion_tokens": 42,
"tokens": 142,
"time_to_first_token": 0.35
}
Model metadata should be recorded in braintrust.metadata:
{
"model": "gemini-2.0-flash"
}
References
- Every other HTTP-middleware integration uses
braintrust.metrics — e.g. trace/contrib/openai/chatcompletions.go, trace/contrib/anthropic/messages.go, trace/contrib/genai/generatecontent.go.
- The Genkit integration (
trace/contrib/genkit/tracegenkit.go) is the closest analogue (typed-SDK callback, Google models) and correctly sets both attributes.
Summary
The ADK (
trace/contrib/adk) integration records token usage as raw OpenTelemetry semantic-convention attributes (gen_ai.usage.prompt_tokens,gen_ai.usage.completion_tokens,gen_ai.usage.total_tokens) instead of thebraintrust.metricsJSON blob that the Braintrust platform expects. It also never setsbraintrust.metadata(model name, temperature, etc.) ortime_to_first_token. This means ADK model-call spans are invisible to Braintrust's token-usage dashboards, cost tracking, and metadata filters.Current behaviour
In
trace/contrib/adk/traceadk.golines 379-388, theAfterModelcallback sets token counts as individual OTel attributes:No
braintrust.metadataattribute is ever set.Expected behaviour
Token usage should be serialised into a
braintrust.metricsJSON attribute (matching the pattern used by every other integration — OpenAI, Anthropic, GenAI, Bedrock, Genkit, Eino, LangChainGo):{ "prompt_tokens": 100, "completion_tokens": 42, "tokens": 142, "time_to_first_token": 0.35 }Model metadata should be recorded in
braintrust.metadata:{ "model": "gemini-2.0-flash" }References
braintrust.metrics— e.g.trace/contrib/openai/chatcompletions.go,trace/contrib/anthropic/messages.go,trace/contrib/genai/generatecontent.go.trace/contrib/genkit/tracegenkit.go) is the closest analogue (typed-SDK callback, Google models) and correctly sets both attributes.