Skip to content

feat(weave): support multi-alias semantic convention keys#6916

Merged
andrewtruong merged 5 commits into
masterfrom
andrew/adk-otel-semconv-aliases
May 21, 2026
Merged

feat(weave): support multi-alias semantic convention keys#6916
andrewtruong merged 5 commits into
masterfrom
andrew/adk-otel-semconv-aliases

Conversation

@andrewtruong
Copy link
Copy Markdown
Collaborator

@andrewtruong andrewtruong commented May 20, 2026

Add support for multi-alias semconv keys.

The main reason for this PR is to allow multiple semconv keys to map to a single concept on the server. This may happen for a number of reasons, including:

  1. Promoting a key from incubating to main;
  2. Two keys just happen to represent the same concept

One specific case of this is with reasoning tokens, which have two forms:

  1. gen_ai.usage.reasoning_tokens; and
  2. gen_ai.usage.experimental.reasoning_tokens

Add `additional_aliases: tuple[str, ...]` to the `Attribute` dataclass
in `weave/trace_server/agents/semconv.py` so a single canonical column
can be fed by multiple wire keys at extraction, filter, and resolution
time. Use it to register two historical wire names for the
`weave.usage.reasoning_tokens` column alongside the new canonical
upstream name `gen_ai.usage.reasoning.output_tokens` from
semantic-conventions#3383 (merged 2026-04-27):

  - `gen_ai.usage.reasoning_tokens` — earlier Weave-internal name; old
    stored spans still carry this on the wire.
  - `gen_ai.usage.experimental.reasoning_tokens` — what ADK emits
    natively before any Weave integration enriches the span.

The mechanism is generic. The reasoning-token migration is its first
user, but any future naming-drift case (other usage metrics, role
spellings, etc.) can register additional aliases without further
plumbing.

Pure-additive on the server: extraction probes weave-canonical first,
gen_ai primary second, additional aliases last. `_ALIAS_TO_CANONICAL`
and `_build_filterable_lookup()` both honour the new aliases so query
filters resolve historical attribute names too.
@andrewtruong andrewtruong requested a review from a team as a code owner May 20, 2026 21:22
@w-b-hivemind
Copy link
Copy Markdown

w-b-hivemind Bot commented May 20, 2026

HiveMind Sessions

2 sessions · 3h 17m · $253

Session Agent Duration Tokens Cost Lines
Refactor Return Types to Tuples
bf55b6a7-4a9c-4709-b727-421223619ad0
claude 20m 83.7K $13 +260 -203
Google ADK Weave OpenTelemetry Integration
e6dbfd63-a7da-4306-895b-99a7450b4c9f
claude 2h 56m 679.9K $241 +5145 -2372
Total 3h 17m 763.6K $253 +5405 -2575
Screenshots

View all sessions in HiveMind →

Run claude --resume bf55b6a7-4a9c-4709-b727-421223619ad0 to pickup where you left off.

@andrewtruong andrewtruong marked this pull request as draft May 20, 2026 21:23
@wandbot-3000
Copy link
Copy Markdown

wandbot-3000 Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

@zbirenbaum zbirenbaum left a comment

Choose a reason for hiding this comment

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

Nice, just one comment, I think this could be simplified a little bit

Comment thread weave/trace_server/agents/semconv.py Outdated
type: AttributeType
description: str
gen_ai_alias: str = "" # OTel gen_ai.* equivalent, if any
gen_ai_alias: str = "" # primary OTel gen_ai.* wire key, if any
Copy link
Copy Markdown
Contributor

@zbirenbaum zbirenbaum May 20, 2026

Choose a reason for hiding this comment

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

Could gen_ai_alias just be changed to accept a string or a tuple? Then there's only one field to deal with
Not sure I understand the comment # primary OTel gen_ai.* wire key. The old comment seemed a bit clearer

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@andrewtruong andrewtruong marked this pull request as ready for review May 21, 2026 21:01
Copy link
Copy Markdown
Member

@bcsherma bcsherma left a comment

Choose a reason for hiding this comment

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

nice, I would recommend we add a test case to ensure that the reasoning token aliases get recognized

@andrewtruong andrewtruong enabled auto-merge (squash) May 21, 2026 22:41
@andrewtruong andrewtruong merged commit 228907f into master May 21, 2026
177 checks passed
@andrewtruong andrewtruong deleted the andrew/adk-otel-semconv-aliases branch May 21, 2026 22:57
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants