feat(weave): support multi-alias semantic convention keys#6916
Conversation
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.
HiveMind Sessions2 sessions · 3h 17m · $253
View all sessions in HiveMind → Run |
|
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=86404cbb2a89bd82667cf97208b8e96ed7e1e11b |
zbirenbaum
left a comment
There was a problem hiding this comment.
Nice, just one comment, I think this could be simplified a little bit
| 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 |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
bcsherma
left a comment
There was a problem hiding this comment.
nice, I would recommend we add a test case to ensure that the reasoning token aliases get recognized
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:
One specific case of this is with reasoning tokens, which have two forms:
gen_ai.usage.reasoning_tokens; andgen_ai.usage.experimental.reasoning_tokens