feat(cross-events): Support metric cross event querying#113703
Merged
nsdeschenes merged 17 commits intomasterfrom Apr 24, 2026
Merged
feat(cross-events): Support metric cross event querying#113703nsdeschenes merged 17 commits intomasterfrom
nsdeschenes merged 17 commits intomasterfrom
Conversation
Let users pick Metrics as a third cross-event type in the Spans explorer alongside Spans and Logs. Metrics rows render the existing MetricSelector inline next to a search bar whose attributes are scoped to the selected metric via createTraceMetricFilter, so users see only attributes that co-occur with that metric. The CrossEvent shape becomes a discriminated union so metrics rows carry the selected TraceMetric (name, type, unit). useCrossEventQueries builds a metricQuery array that prepends metric.name, metric.type, and metric.unit (when present) onto the user's filter string, guaranteeing the identity fields reach the backend on every request. The backend metricQuery param is already accepted by useTraces, useExploreTracesTable and useProgressiveQuery. Refs EXP-895 Co-Authored-By: Claude <noreply@anthropic.com>
Emit cross_event_metric_query_count alongside the existing log and span counters on trace.explorer.metadata so dashboards can see how often the new metrics cross-event type is used. Refs EXP-895 Co-Authored-By: Claude <noreply@anthropic.com>
Two related robustness fixes for the metrics cross-event flow: - Guard `useCrossEventQueries` on `isCompleteTraceMetric(metric)` so a metric entry with an empty `type` no longer emits a malformed `metric.type:` filter. Previously only `metric.name` was checked. - In `getCrossEventsFromLocation`, filter malformed entries instead of rejecting the whole array, so one bad entry can't drop sibling span/log cross-events. Also adds `isCompleteTraceMetric` alongside `isEmptyTraceMetric` to make the "complete enough to query" contract explicit for future consumers.
Pass the selected metric name as a namespace to the cross-event metrics search query builder so `/recent-searches/` results are scoped to the active metric. Disable the search query builder until a metric is selected since recent searches require a namespace, and remount the provider on metric change to avoid stale state.
…-cross-event-querying
Move the cross event querying dropdown and cross event search bar components out of spansTabSearchSection.tsx and into a dedicated static/app/views/explore/spans/crossEvents/ directory. No behavior change.
Group the metric.name, metric.type, and metric.unit filters for metric cross-event queries in parentheses and append the user-provided query as free text. This keeps the metric identity constraints intact when the user query contains boolean operators that would otherwise bind to a single filter.
Knip flagged EMPTY_TRACE_METRIC as an unused export. It is only used within the same module, so drop the export keyword. Co-Authored-By: Claude <noreply@anthropic.com>
Replace the static crossEventDropdownItems constant with a getCrossEventDropdownItems() helper so the item list can vary per caller. No behavior change. Co-Authored-By: Claude <noreply@anthropic.com>
…cess Only show the Metrics option in the cross-event dropdown when the organization has access to the trace metrics UI (canUseMetricsUI). Co-Authored-By: Claude <noreply@anthropic.com>
…rics access The dataset CompactSelect in SpansTabCrossEventSearchBars hard-coded the metrics option, letting users without the tracemetrics-enabled feature switch an existing cross event to metrics and bypass the feature gate applied to the add-dropdown. Route the dataset options through a getCrossEventDatasetOptions helper that applies the same canUseMetricsUI check. Co-Authored-By: Claude <noreply@anthropic.com>
narsaynorath
approved these changes
Apr 24, 2026
Member
narsaynorath
left a comment
There was a problem hiding this comment.
Just a small update to use another helper, but otherwise lgtm 👍
Relocate the helper from the dashboards widget hook into `views/explore/metrics/utils` so it can be shared by other explore consumers without pulling a dependency on dashboards code.
…ric queries Replace the inline metric identity filter logic in `useCrossEventQueries` with the shared `createTraceMetricEventsFilter` helper so the unit-less metric case is handled consistently (matching both `!has:metric.unit` and `metric.unit:none`).
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5a3918b. Configure here.
…ss-events-enable-metric-cross-event-querying # Conflicts: # static/app/views/explore/metrics/metricGraph/index.tsx # static/app/views/explore/metrics/utils.tsx
…t search addFreeText coerces its argument into a single FREE_TEXT token, which formatString then wraps in quotes whenever the value contains spaces. A user query like 'env:prod status:ok' was being serialized as a single quoted free-text search instead of two ANDed filters. Concatenate the identity filter and the user query as strings so the backend receives each filter as its own token.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR adds in support for cross-event querying with the metrics dataset. As well, taken the time to move the cross-event stuff into it's own directory and files, as it was starting to balloon the size of the spans tab search section file.
Closes EXP-895
Example: