Skip to content

feat(explore): Expose sentry.links for filtering and grouping on spans - #125741

Merged
shellmayr merged 6 commits into
masterfrom
shellmayr/feat/span-links-explore-backend
Oct 6, 2026
Merged

shellmayr merged 6 commits into
masterfrom
shellmayr/feat/span-links-explore-backend

Conversation

@shellmayr

@shellmayr shellmayr commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Make the sentry.links span attribute queryable from the events endpoint so Explore can filter and group on span links, without exposing the raw JSON anywhere else.

  • Keep sentry.links marked private and 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.
  • The validate endpoint grants sentry.links for the spans dataset, so Explore accepts it as a column, group-by, and filter.
  • The trace item details endpoint keeps dropping the attribute, so the span details slideout, the Explore row expansion, and API consumers never see the internal JSON. The parsed links field is unchanged.
  • The value stays the JSON string written at ingest, so filters use a wildcard on a linked span id, e.g. sentry.links:*8873a98879faf06d*. Group-by groups on the full JSON string.
  • Add a Snuba test that stores linked spans, filters on a linked span id, selects the column, and groups by it. Add a validate test for a private field allowed by the ACL.

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

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]>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 28, 2026
@shellmayr
shellmayr marked this pull request as ready for review September 28, 2026 14:25
@shellmayr
shellmayr requested review from a team as code owners September 28, 2026 14:25
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]>

@mjq mjq left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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]>
shellmayr and others added 2 commits October 6, 2026 15:36
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]>
@shellmayr

Copy link
Copy Markdown
Member Author

@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 mjq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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!

@shellmayr
shellmayr merged commit 218a719 into master Oct 6, 2026
74 checks passed
@shellmayr
shellmayr deleted the shellmayr/feat/span-links-explore-backend branch October 6, 2026 15:17
s1gr1d added a commit that referenced this pull request Oct 7, 2026
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"
/> |
s1gr1d added a commit that referenced this pull request Oct 9, 2026
…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**.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants