Repository navigation
feat(explore): Expose sentry.links for filtering and grouping on spans - #125741
Conversation
Span links are stored on each span as the JSON string attribute sentry.links. The attribute was marked private, so the events endpoint rejected it as a field, filter, or group-by key. Drop the private flag so Explore can filter with a wildcard on a linked span id and group by the links value. The value stays the JSON string written at ingest. Co-Authored-By: Claude Fable 5.1 <[email protected]>
A span with no sentry.links attribute comes back as None from the events endpoint, not as an empty string. Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
This is a little less than ideal for a couple reasons:
- it exposes
sentry.links' value to the span details UIs (expanding an Explore table row, span details slideout in trace waterfall). This was intended to be a private serialization format (and as per #125749 we didn't even manage to serialize it consistently). We don't really want any users to rely on its format, including searching on the JSON which is subject to change. - With better object support coming soon in EAP, if we were going to expose links, it would be as an object rather than the serialized JSON.
But, I don't want to block you.
As-written, the raw sentry.links attribute is blocked from being suggested in search bars (via isKnownAttribute here). That's good.
It's not blocked from span details views though, and I'd prefer if we blocked it there too to minimize exposure of the internal format. A more robust way to do this would be in the trace item details endpoint so that it is hidden from all consumers (human and agent), but that would be a new special case. The faster way would be to apply isKnownAttribute on the frontend for the details panes (this is the consistent option, since it's already how we deal with search). That's probably fine for now - the whole mechanism for defining attributes and their privacy is due for an overhaul so I don't have a strong opinion either way. We'll keep this use case (where we want to support filtering but not advertise the value) in mind when we do.
When object support lands we should be able to make links properly searchable and avoid these extra hoops.
…ds ACL Dropping the private flag exposed the raw links JSON in the trace item details response and in the span details panes. The format is internal and will change once span links become their own trace items. Restore private=True and instead list sentry.links in the fields ACL of the events endpoint and the Explore data export. The resolver already lets private columns through when the ACL names them, so filter, select, and group-by keep working while the details endpoint keeps dropping the attribute. Restore the validate and attribute mapping tests that assert the attribute stays private. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The events endpoint accepted sentry.links through its fields ACL, but the validate endpoint still resolved spans with an empty ACL and reported the field as invalid. Explore validates columns, group-bys, and the search query through that endpoint, so the UI would have dropped the field. Define the spans fields ACL once next to the span definitions and use it in the events endpoint, the Explore data export, and the validate endpoint. Add a validate test for a private field allowed by the ACL. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The shared spans ACL pulled time_spent_percentage into the validate endpoint, which is unrelated to span links. Drop the shared constant and add sentry.links inline where each endpoint already grants its fields. The validate endpoint grants only the attribute for the spans dataset. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@mjq thanks for pointing out the difficulties here, tried to work it into the PR and curious about your feedback! it seems a bit weird though that we have to now manually pipe this into SearchResolverConfig etc. which seems to be necssary |
mjq
left a comment
There was a problem hiding this comment.
@shellmayr Thanks very much! I agree re: needing this special case in SearchResolverConfig but I think this is the cleanest approach available today (good find!) and AFAICT fulfills both of our requirements, and changes are coming that should make this easier to express in the future. 👍 Thanks again!
We can access the attributes of span links now and show a more useful representation of span links. - Ref: #125749 --- - Span links in the drawer are now grouped by `sentry.link.type` (e.g. `previous_trace`), not `span_link_1`. Untyped links show as `link`, and repeated types get a counter. - Adds a shared `getSpanLinkType` helper - Updates TODO comments that needed change since merging #125741 ### Example With multiple links: when a link type appears more often, it's numbered. Be aware that the very nested `attributes.sentry.link.type` was only shown since this PR (let us show the attributes): #125749 One "Before" before (you know, before the span links were unwrapped), there was just the `spanId` and `traceId` | Before | After | |---|---| | <img width="300" height="579" alt="image" src="https://github.com/user-attachments/assets/14ae0665-c1e9-41f3-a2be-94e62b8af862" /> | <img width="264" height="579" alt="image" src="https://github.com/user-attachments/assets/afa59996-4cfe-45e9-9c2e-33dfd07233b4" /> |
…ribute) (#126702) Since #125741 we can filter `sentry.links`, which lets us improve "Previous trace". SDKs send the `previous_trace` link together with the `sentry.previous_trace` attribute. - "Previous trace" now reads the root span's `previous_trace` link instead of the attribute. - If the link has no sampling decision, the trace view still searches for the previous trace's span to check that it exists. - "Next trace" still searches the attribute. We can filter `sentry.links`, but only with a wildcard on private JSON, which cannot filter by link type or sampling. Removing the attribute **needs links as EAP objects**.
Make the
sentry.linksspan attribute queryable from the events endpoint so Explore can filter and group on span links, without exposing the raw JSON anywhere else.sentry.linksmarkedprivateand add it to the fields ACL of the events endpoint and the Explore data export. The resolver already lets private columns through when the ACL names them.sentry.linksfor the spans dataset, so Explore accepts it as a column, group-by, and filter.linksfield is unchanged.sentry.links:*8873a98879faf06d*. Group-by groups on the full JSON string.The attribute was made private in #95605 to avoid a migration burden once span links become their own trace items. The ACL route keeps the serialization format private until object support in EAP lets links become properly searchable.
Related to this: getsentry/sentry-javascript#24227