Skip to content

ref(AttributeValues): add arrays to response - #412

Merged
MeredithAnya merged 5 commits into
mainfrom
meredith/EAP-698
Aug 25, 2026
Merged

ref(AttributeValues): add arrays to response#412
MeredithAnya merged 5 commits into
mainfrom
meredith/EAP-698

Conversation

@MeredithAnya

@MeredithAnya MeredithAnya commented Aug 25, 2026

Copy link
Copy Markdown
Member

Changes the TraceItemAttributeValues response so that instead of returning two
parallel lists (values and counts) that callers have to zip together by index,
we return a single list of ValueData objects. Each one carries everything we know
about a single attribute value:

message ValueData {
  AttributeValue value = 1;
  int64 count = 2;
  google.protobuf.Timestamp last_seen = 3;
}

Why:

  • Non-string values. value is an AttributeValue rather than a string, so
    the endpoint can return values for non-string attributes, including arrays
    (e.g. the attribute_array_string column) via AttributeValue.val_array
    this was the original motivation for this PR, see the draft Snuba
    implementation in ref(attrvalues): support array-of-string attributes and typed value_data snuba#8390.
  • Room to grow. Adding per-value metadata is now a new field on ValueData
    instead of another parallel list. last_seen is the first of those.

values and counts are marked deprecated rather than removed, so existing
callers keep working until they migrate to value_data.

@MeredithAnya
MeredithAnya requested a review from a team as a code owner August 25, 2026 00:28
@linear-code

linear-code Bot commented Aug 25, 2026

Copy link
Copy Markdown

EAP-698

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 25, 2026, 10:28 PM

@MeredithAnya MeredithAnya changed the title ref(AttributeValues): add AttributeArrayValue to response ref(AttributeValues): add arrays to response Aug 25, 2026

@phacops phacops left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it would be nice to plan to return a count and a last seen for each value we see.

So maybe, we switch to having a repeated type that countains a oneof of scalar (string, int, double, bool) and a count and last_seen field as well.

Comment thread proto/sentry_protos/snuba/v1/endpoint_trace_item_attributes.proto Outdated
Comment thread proto/sentry_protos/snuba/v1/endpoint_trace_item_attributes.proto Outdated
@MeredithAnya

Copy link
Copy Markdown
Member Author

I think it would be nice to plan to return a count and a last seen for each value we see.

So maybe, we switch to having a repeated type that countains a oneof of scalar (string, int, double, bool) and a count and last_seen field as well.

This isn't hitting the eap_item_co_occurring_attrs table so there isn't the last_seen field. Also right now the endpoint accepts on strings or bool scalar types and it converts the bool type to string response, so was going to have the response be consistent there for arrays

Comment thread proto/sentry_protos/snuba/v1/endpoint_trace_item_attributes.proto Outdated
@MeredithAnya
MeredithAnya merged commit d2937c3 into main Aug 25, 2026
17 checks passed
MeredithAnya added a commit to getsentry/snuba that referenced this pull request Aug 31, 2026
…ata (#8390)

Adds array-of-string support to `TraceItemAttributeValues`, and returns
values as
typed `AttributeValue`s with per-value metadata instead of plain
strings.

Depends on getsentry/sentry-protos#412 (released
in
`sentry-protos` 0.64.1, which this PR pins).

### What changed

- **`TYPE_ARRAY_STRING` keys are now enumerable.**
`attributes_array_string` is
added to the type → column map, so requesting an array-of-string key
returns
  its distinct array values instead of `BadSnubaRPCRequestException`.
- **New `value_data` field.** Every value is returned as a
`ValueData { value: AttributeValue, count, last_seen }`. Because the
value is a
typed `AttributeValue`, arrays come back whole (`val_array`) and
booleans come
back as real `val_bool` — neither of which the string-only response
could
express. Conversion reuses `get_converter_for_type` from the table
resolver
(renamed from `_get_converter_for_type`) so typing matches
`TraceItemTable`.
- **New `last_seen` per value.** The outer query selects
`max(timestamp) AS last_seen`, with `timestamp` projected through the
inner
query. Like `count()`, this is an aggregate over the 10k-row sample the
inner
  query takes, not over every matching item — noted in the docstring.
- **`datetime` coercion helper moved to `common.py`** as `as_datetime`,
shared
  with `endpoint_trace_item_attribute_names.py` (native driver returns a
  `datetime`, HTTP returns an ISO string).

### Backwards compatibility

The deprecated `values`/`counts` fields are unchanged for string and
boolean
keys — booleans keep the lowercase `"true"`/`"false"` form that callers
feed
back in as filter inputs. Array keys populate only `value_data`: the
string
fields cannot represent an array, and this endpoint rejected array keys
before
`value_data` existed, so no caller can be relying on them. The page
token is now
derived from `value_data` so array responses paginate correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants