fix(rpc): honor deprecated attribute keys in trace item attribute values#7853
fix(rpc): honor deprecated attribute keys in trace item attribute values#7853
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes the Trace Item Attribute Values v1 RPC to return values when clients request a canonical attribute name but events only contain the deprecated/alias key, aligning the endpoint’s filtering behavior with attribute_key_to_expression coalescing.
Changes:
- Update the attribute existence filter to OR across the requested key and any coalesce/deprecated targets.
- Apply
add_existence_check_to_subscriptable_referencesto the inner query to keep missing-key behavior consistent with other EAP RPC queries. - Add an integration test that writes values under
db.systemand queriesdb.system.name.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
snuba/web/rpc/v1/trace_item_attribute_values.py |
Extends attribute existence checks to cover coalesced keys and adds subscriptable existence wrapping to the inner query. |
tests/web/rpc/v1/test_trace_item_attribute_values_v1.py |
Adds coverage for canonical-vs-deprecated attribute key lookups returning distinct values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _map_key_names_for_existence_check(request_key: AttributeKey) -> list[str]: | ||
| """Map key names that may hold values (canonical plus deprecated/alias names).""" | ||
| names = [request_key.name] | ||
| for alt in ATTRIBUTES_TO_COALESCE.get(request_key.name, ()): |
There was a problem hiding this comment.
ATTRIBUTES_TO_COALESCE values are set[str], so iterating them makes the generated OR condition order nondeterministic across runs (and across Python hash seeds). This can make query serialization/caching/metrics noisier and can complicate debugging. Consider iterating a sorted list of alternates (e.g. for alt in sorted(...)) to keep the query AST stable.
| for alt in ATTRIBUTES_TO_COALESCE.get(request_key.name, ()): | |
| for alt in sorted(ATTRIBUTES_TO_COALESCE.get(request_key.name, ())): |
https://linear.app/getsentry/issue/EAP-459/attributevaluesrequest-returns-empty-results-for-attributes-with
Fix the Trace Item Attribute Values RPC when clients request the canonical attribute name but data is stored only under a deprecated or alias key (e.g.
db.system.namevsdb.system).attribute_key_to_expressionalready coalesces those names viaATTRIBUTES_TO_COALESCE, but the endpoint only checkedhas(attributes_string, <request key>), so inner rows that held values exclusively on the legacy key never matched. We now OR existence checks across the canonical name and any coalesce targets, and runadd_existence_check_to_subscriptable_referenceson the inner query so behavior stays aligned with other EAP RPC paths.Adds an integration test that writes
db.systemand requestsdb.system.name, asserting the returned distinct values.Refs: