ref(AttributeValues): add arrays to response - #412
Conversation
|
The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).
|
d9af69f to
3cd2ad4
Compare
phacops
left a comment
There was a problem hiding this comment.
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 |
bad8a26 to
b8f6d7e
Compare
909a6dd to
d9d5778
Compare
…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.
Changes the
TraceItemAttributeValuesresponse so that instead of returning twoparallel lists (
valuesandcounts) that callers have to zip together by index,we return a single list of
ValueDataobjects. Each one carries everything we knowabout a single attribute value:
Why:
valueis anAttributeValuerather than astring, sothe endpoint can return values for non-string attributes, including arrays
(e.g. the
attribute_array_stringcolumn) viaAttributeValue.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.
ValueDatainstead of another parallel list.
last_seenis the first of those.valuesandcountsare markeddeprecatedrather than removed, so existingcallers keep working until they migrate to
value_data.