Commit 42c2ca8
authored
feat(traces): expose custom span attributes and improve agent guidance (#623)
## Summary
Addresses feedback from an AI agent field report about Sentry CLI
usability. The critical gap was that custom span attributes (like
`gen_ai.usage.input_tokens`, `pi.session.id`) were completely invisible
via CLI — this PR fixes that across all three span/trace commands.
### Custom attribute access (critical)
- **`span view`**: Fetches full attributes from the
`trace-items/{itemId}/` endpoint (same as Sentry frontend's span detail
sidebar). All custom OTEL attributes now appear in both JSON and human
output with no configuration needed.
- **`trace view`**: `--fields` values that aren't standard output fields
are forwarded as `additional_attributes` query params to the trace
detail API.
- **`span list`**: `--fields` now drives API field selection — unknown
field names are requested as additional `field` params from the events
API. Includes `gen_ai` group alias that expands to common AI
observability fields.
### Agent guidance improvements
- Added `--since` as an alias for `--period` on all list commands (the
most natural flag name for time filtering)
- Added "Quick Reference" section to agent guidance docs covering
correct patterns for time filtering, org/project scoping, trace ID
usage, and valid dataset names
- Regenerated SKILL.md
### Quality of life
- Filter zero-valued web vitals measurements from `trace view` JSON
output (~40% size reduction for typical traces)
- Added `EVENTS_API_DATASETS` shared constant and documented valid
dataset names in api command docs
- Widened `TraceSpan` type to include all fields the trace detail API
actually returns (`measurements`, `additional_attributes`, `sdk_name`,
`errors`, `occurrences`, etc.)1 parent 5192f92 commit 42c2ca8
File tree
12 files changed
+691
-52
lines changed- docs/src/content/docs
- commands
- plugins/sentry-cli/skills/sentry-cli
- src
- commands
- span
- trace
- lib
- api
- formatters
- types
- test/commands/trace
12 files changed
+691
-52
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
153 | 188 | | |
154 | 189 | | |
155 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
98 | 102 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
163 | 198 | | |
164 | 199 | | |
165 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
60 | 133 | | |
61 | 134 | | |
62 | 135 | | |
| |||
208 | 281 | | |
209 | 282 | | |
210 | 283 | | |
| 284 | + | |
| 285 | + | |
211 | 286 | | |
212 | 287 | | |
213 | 288 | | |
214 | 289 | | |
215 | 290 | | |
216 | 291 | | |
217 | 292 | | |
| 293 | + | |
| 294 | + | |
218 | 295 | | |
219 | 296 | | |
220 | 297 | | |
| |||
228 | 305 | | |
229 | 306 | | |
230 | 307 | | |
231 | | - | |
| 308 | + | |
232 | 309 | | |
233 | 310 | | |
234 | 311 | | |
| |||
266 | 343 | | |
267 | 344 | | |
268 | 345 | | |
| 346 | + | |
| 347 | + | |
269 | 348 | | |
270 | 349 | | |
271 | 350 | | |
| |||
278 | 357 | | |
279 | 358 | | |
280 | 359 | | |
281 | | - | |
| 360 | + | |
282 | 361 | | |
283 | 362 | | |
284 | 363 | | |
| |||
311 | 390 | | |
312 | 391 | | |
313 | 392 | | |
| 393 | + | |
314 | 394 | | |
315 | 395 | | |
316 | 396 | | |
317 | 397 | | |
318 | 398 | | |
319 | 399 | | |
320 | 400 | | |
321 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
322 | 404 | | |
323 | 405 | | |
324 | 406 | | |
| |||
339 | 421 | | |
340 | 422 | | |
341 | 423 | | |
342 | | - | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
343 | 432 | | |
344 | 433 | | |
345 | 434 | | |
| |||
354 | 443 | | |
355 | 444 | | |
356 | 445 | | |
357 | | - | |
| 446 | + | |
358 | 447 | | |
359 | 448 | | |
360 | 449 | | |
| |||
382 | 471 | | |
383 | 472 | | |
384 | 473 | | |
| 474 | + | |
385 | 475 | | |
386 | 476 | | |
387 | 477 | | |
| |||
394 | 484 | | |
395 | 485 | | |
396 | 486 | | |
397 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
398 | 490 | | |
399 | 491 | | |
400 | 492 | | |
| |||
415 | 507 | | |
416 | 508 | | |
417 | 509 | | |
418 | | - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
419 | 519 | | |
420 | 520 | | |
421 | 521 | | |
| |||
498 | 598 | | |
499 | 599 | | |
500 | 600 | | |
501 | | - | |
| 601 | + | |
| 602 | + | |
502 | 603 | | |
503 | 604 | | |
504 | 605 | | |
| |||
0 commit comments