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
docs: add tracemetrics dataset guidance and validate aggregate format (#636)
## Summary
- Add comprehensive documentation for the `tracemetrics` dataset to
prevent future agents from using the wrong query format
- Add `validateAggregateNames()` guard that rejects span-style
aggregates when `--dataset tracemetrics` is used
- Document common dashboard widget mistakes in agent guidance
## Context
While building the CLI Performance dashboard, several mistakes were made
with custom metrics widgets that could have been prevented with better
docs and validation:
1. **Used `--dataset metrics` with MRI format** (`d:custom/name@unit`)
instead of `--dataset tracemetrics` with comma-separated format
(`aggregation(value,name,type,unit)`) — SDK v10+ emits `trace_metric`
items, not standalone custom metrics
2. **Wrong MRI unit suffixes** (e.g., `@millisecond` when SDK emits with
no unit → `@none`) — caused "Internal Error" on every metrics widget
3. **Missing `--limit` on grouped widgets** — API rejects grouped
queries without limit
4. **`--sort` referencing fields not in `--query`** — caused 400 errors
(e.g., sorting by `count()` after removing it from aggregates)
5. **Tried to aggregate span attributes** (`avg:dsn.files_collected`) —
span attributes are metadata, not aggregatable measurements
## Changes
| File | Change |
|------|--------|
| `docs/src/content/docs/agent-guidance.md` | Dataset selection guide,
tracemetrics format table with examples, common dashboard widget
mistakes |
| `src/types/dashboard.ts` | `isTracemetricsAggregate()` validator +
tracemetrics branch in `validateAggregateNames()` |
| `AGENTS.md` | Lore entry documenting tracemetrics gotchas |
| `plugins/sentry-cli/skills/sentry-cli/SKILL.md` | Auto-regenerated |
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* **CLI telemetry command tags use sentry. prefix with dots not bare names**: The \`buildCommand\` wrapper sets the \`command\` telemetry tag using the full Stricli command prefix joined with dots: \`sentry.issue.explain\`, \`sentry.issue.list\`, \`sentry.api\`, etc. — NOT bare names like \`issue.explain\`. When querying Sentry Discover or building dashboard widgets, always use the \`sentry.\` prefix. Verify actual tag values with a Discover query (\`field:command, count()\`, grouped by \`command\`) before assuming the format.
954
954
955
+
* **Dashboard tracemetrics dataset uses comma-separated aggregate format**: SDK v10+ custom metrics (`Sentry.metrics.distribution()`, `.gauge()`, `.count()`) emit `trace_metric` envelope items. Dashboard widgets for these MUST use `--datasettracemetrics` with aggregate format `aggregation(value,metric_name,metric_type,unit)` — e.g., `p50(value,completion.duration_ms,distribution,none)`. The `unit` parameter must match the SDK emission exactly: `none` if no unit specified, `byte` for memory metrics, `second` for uptime. `tracemetrics` only supports `line`, `area`, `bar`, `big_number`, `categorical_bar` display types — no `table` or `stacked_area`. Widgets with `--group-by` always require `--limit`. Sort expressions must reference aggregates present in `--query`.
* **Use toMatchObject not toEqual when testing resolution results with optional fields**: When \`resolveProjectBySlug()\` or \`resolveOrgProjectTarget()\` adds optional fields (like \`projectData\`) to the return type, tests using \`expect(result).toEqual({ org, project })\` fail because \`toEqual\` requires exact match. Use \`toMatchObject({ org, project })\` instead — it checks the specified subset without failing on extra properties. This affects tests across \`event/view\`, \`log/view\`, \`trace/view\`, and \`trace/list\` test files.
Copy file name to clipboardExpand all lines: docs/src/content/docs/agent-guidance.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,9 +128,7 @@ Display types with default sizes:
128
128
129
129
Use **common** types for general dashboards. Use **specialized** only when specifically requested. Avoid **internal** types unless the user explicitly asks.
130
130
131
-
Available datasets: `spans` (default, covers most use cases), `discover`, `issue`, `error-events`, `transaction-like`, `metrics`, `logs`, `tracemetrics`, `preprod-app-size`.
132
-
133
-
Run `sentry dashboard widget --help` for the full list including aggregate functions.
131
+
Available datasets: `spans` (default), `tracemetrics`, `discover`, `issue`, `error-events`, `logs`. Run `sentry dashboard widget --help` for dataset descriptions, query formats, and examples.
Copy file name to clipboardExpand all lines: plugins/sentry-cli/skills/sentry-cli/SKILL.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,9 +138,7 @@ Display types with default sizes:
138
138
139
139
Use **common** types for general dashboards. Use **specialized** only when specifically requested. Avoid **internal** types unless the user explicitly asks.
140
140
141
-
Available datasets: `spans` (default, covers most use cases), `discover`, `issue`, `error-events`, `transaction-like`, `metrics`, `logs`, `tracemetrics`, `preprod-app-size`.
142
-
143
-
Run `sentry dashboard widget --help` for the full list including aggregate functions.
141
+
Available datasets: `spans` (default), `tracemetrics`, `discover`, `issue`, `error-events`, `logs`. Run `sentry dashboard widget --help` for dataset descriptions, query formats, and examples.
0 commit comments