Skip to content

Cannot filter spans by custom (string/boolean) attributes #713

@Eslam-mohammed-anwar

Description

@Eslam-mohammed-anwar

Cannot filter spans by custom (string/boolean) attributes — query returns 0 while Sentry Explore returns data

Plugin version

grafana-sentry-datasource v2.2.4 (latest, released 2026-03-03)
Grafana datasource configured against Sentry org , EAP spans dataset (useRpc=1).

What happened

Filtering a Spans query by a custom span attribute returns 0 results through the plugin, even though the same query returns data in Sentry's own Explore UI. Standard attributes (span.name, span.op, span.status, span.duration) filter correctly. Only custom attributes fail.

Steps to reproduce

In Grafana → Explore, Sentry datasource, Query type = Spans, time range = last 24h:

# Query Fields Result
1 span.name:vendor-menu count() 413,488
2 span.name:vendor-menu menu.is_empty:True count() 0
3 span.name:vendor-menu menu.is_empty:1 count() 0
4 span.name:vendor-menu menu.is_empty:true count() 0
5 span.name:vendor-menu has:menu.is_empty count() 0
6 span.name:vendor-menu tags[menu.is_empty,number]:1 count() 0
7 span.name:vendor-menu menu.is_empty, count() attribute column silently dropped

The same menu.is_empty:True filter returns ~88 spans in Sentry's Explore UI over a 2h window.

Expected

Filtering and/or selecting custom span attributes should return the same results the EAP spans dataset returns in Sentry's Explore UI.

Actual

  • Custom-attribute filters match nothing (0 results) regardless of value syntax (True/true/1) or typed form (tags[key,number]).
  • Custom attributes requested as display columns are silently omitted from the response.
  • has:<custom_attr> also returns 0, i.e. the attribute key isn't seen at all by the query path.

Evidence the filter reaches Sentry intact (not a plugin-side rewrite)

pkg/sentry/spans.go forwards the user's query string verbatim:

params.Set("dataset", "spans")
params.Set("useRpc", "1")
params.Set("query", gei.Query)            // forwarded unmodified
for _, field := range gei.Fields {
    params.Add("field", field)
}

The resolved Sentry URL (from the panel's executedQueryString) confirms the filter is present:

https://sentry.io/api/0/organizations/poc/events/
  ?dataset=spans&useRpc=1
  &field=count()
  &query=span.name:vendor-menu+menu.is_empty:True
  &start=...&end=...

So the 0 is returned by Sentry's EAP/RPC events endpoint, not produced by the plugin dropping the filter.

Likely root cause

pkg/sentry/attributes.go (the attribute-discovery path that populates the Fields dropdown) hardcodes the type when querying trace-items/attributes/:

params.Set("itemType", "spans")
params.Set("attributeType", "number")   // only numeric attributes are ever discovered

There is no handling for string/boolean custom attributes and no typed-attribute reference (tags[key,string]) wired into the filter path. Custom attributes like menu.is_empty therefore never resolve for filtering or column extraction. (Note: tags[menu.is_empty,number]:1 was also tried and still returns 0, so even the numeric typed form does not filter.)

Impact

We're evaluating Sentry span signals as canary rollback triggers. Any signal that depends on a custom attribute (e.g. menu.is_empty, add_to_cart.success, payment.status) cannot be expressed through the plugin, forcing teams to re-instrument (emit a dedicated marker span or overload span.status) purely to work around the datasource. This is a significant adoption blocker for span-based alerting/canary use.

Questions / requests

  1. Is custom (string/boolean) attribute filtering on the EAP spans dataset intended to be supported? If so, this looks like a bug.
  2. If a typed reference is required, what is the exact filter syntax the plugin expects/forwards (e.g. tags[menu.is_empty,string]:"true")? The Fields dropdown advertises these tags but none of the documented/guessed forms filter.
  3. Could attributes.go fetch attributeType=string (and boolean) in addition to number so custom attributes are discoverable and filterable?

Environment

  • Plugin: grafana-sentry-datasource v2.2.4
  • Sentry: SaaS (sentry.io), org , EAP spans (useRpc=1)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Incoming

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions