You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 26073ae
Browse filesBrowse the repository at this point in the historyBrowse files
feat(search-events): Add tracemetrics dataset support (#902)
Add support for Sentry's current-generation span metrics in
search_events and list_events.
The previous attempt in #899 targeted the wrong dataset. The current
Sentry path uses dataset=tracemetrics on the events endpoint, raw metric
aggregate expressions such as
p95(value,http.request.duration,distribution,millisecond), and Metrics
page URLs under /explore/metrics/. This updates the MCP query builder,
formatting, mocks, tests, generated definitions, and docs to match that
behavior.
This also preserves raw aggregate sort expressions for tracemetrics so
grouped metric queries keep working instead of being rewritten into
Discover-style aliases.
---------
Co-authored-by: Codex <codex@openai.com>
Copy file name to clipboardExpand all lines: docs/search-events-api-patterns.md
+44-20Lines changed: 44 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,23 +2,23 @@
2
2
3
3
## Overview
4
4
5
-
The `search_events` tool provides a unified interface for searching Sentry events across different datasets (errors, logs, spans). This document covers the API patterns, query structures, and best practices for both individual event queries and aggregate queries.
5
+
The `search_events` tool provides a unified interface for searching Sentry events across different datasets (`errors`, `logs`, `spans`, and `metrics`). This document covers the API patterns, query structures, and best practices for both individual event queries and aggregate queries.
6
6
7
7
## API Architecture
8
8
9
-
### Legacy Discover API vs Modern EAP API
9
+
### Discover-Style API vs Modern EAP API
10
10
11
-
Sentry uses two different API architectures depending on the dataset:
11
+
Sentry uses two different query-building patterns depending on the dataset, even though they share the same `/events/` endpoint:
-**Tracemetrics dataset**: Focus on `metric.name`, `metric.type`, `metric.unit`, `value`, and metric-aware aggregates like `p95(value,http.request.duration,distribution,millisecond)`
88
96
89
97
### Key Technical Constraints
90
98
91
99
-**Logs timestamp handling**: Logs don't support query-based timestamp filters like `timestamp:-1h`. Instead, use `statsPeriod=24h` parameter
92
100
-**Project ID mapping**: API requires numeric project IDs, not slugs. Tool automatically converts project slugs to IDs
93
-
-**Parallel attribute fetching**: For spans/logs, fetches both string and number attribute types in parallel for better performance
94
-
-**itemType specification**: Must use "logs" (plural) not "log" for the trace-items attributes API
101
+
-**Parallel attribute fetching**: For spans/logs/metrics, fetches both string and number attribute types in parallel for better performance
102
+
-**itemType specification**: Must use `logs` and `tracemetrics` exactly for the trace-items attributes API
103
+
-**Tracemetrics sort handling**: Aggregate sort expressions like `-p95(value,...)` must be sent to the API unchanged
104
+
-**Tracemetrics URL generation**: Explorer links must point at `/explore/metrics/` with JSON-encoded `metric=` parameters, not the traces or logs Explore pages
95
105
96
106
### Tool Removal
97
107
@@ -124,16 +134,17 @@ search_events({
124
134
### Completed Features
125
135
126
136
1.**Custom attributes API integration**:
127
-
- ✅ `/organizations/{org}/trace-items/attributes/` for spans/logs with parallel string/number fetching
137
+
- ✅ `/organizations/{org}/trace-items/attributes/` for spans/logs/metrics with parallel string/number fetching
128
138
- ✅ `/organizations/{org}/tags/` for errors (legacy API)
129
139
130
140
2.**Dataset mapping**:
131
-
- ✅ User specifies `logs` → API uses `ourlogs`
132
141
- ✅ User specifies `errors` → API uses `errors`
133
142
- ✅ User specifies `spans` → API uses `spans`
143
+
- ✅ User specifies `logs` → API uses `logs`
144
+
- ✅ User specifies `metrics` → API uses `tracemetrics`
134
145
135
146
3.**URL Generation**:
136
-
- ✅ Uses appropriate explore path based on dataset (`/explore/traces/`, `/explore/logs/`)
147
+
- ✅ Uses appropriate explore path based on dataset (`/discover/results/`, `/explore/traces/`, `/explore/logs/`, `/explore/metrics/`)
137
148
- ✅ Query and project parameters properly encoded with numeric project IDs
138
149
139
150
4.**Error Handling**:
@@ -146,14 +157,15 @@ search_events({
146
157
- ✅ Console format for logs with severity emojis
147
158
- ✅ Alert cards for errors with color-coded levels
148
159
- ✅ Performance timeline for spans with duration bars
160
+
- ✅ Aggregate-table and sample formatting for metrics
149
161
150
162
## Success Criteria - All Complete ✅
151
163
152
164
- ✅ **Accurate translation of common query patterns** - GPT-5 with comprehensive system prompts
153
165
- ✅ **Proper handling of org-specific custom attributes** - Parallel fetching and integration
154
166
- ✅ **Seamless migration from old tools** - find_errors, find_transactions removed from exports
0 commit comments