diff --git a/apps/cli-docs/src/fragments/commands/alert.md b/apps/cli-docs/src/fragments/commands/alert.md index 1d47e382b..ee32b001f 100644 --- a/apps/cli-docs/src/fragments/commands/alert.md +++ b/apps/cli-docs/src/fragments/commands/alert.md @@ -53,8 +53,8 @@ sentry alert issues delete my-org/my-project/12345 --dry-run sentry alert metrics create my-org \ --name "P95 Latency" \ --query "environment:prod" \ - --aggregate "p95(transaction.duration)" \ - --dataset transactions \ + --aggregate "p95(span.duration)" \ + --dataset spans \ --time-window 5 \ --trigger '{"alertThreshold":500,"actions":[{"id":"sentry.mail.actions.NotifyEmailAction","targetType":"Team","targetIdentifier":1}]}' ``` diff --git a/packages/cli/plugins/sentry-cli/skills/sentry-cli/references/alert.md b/packages/cli/plugins/sentry-cli/skills/sentry-cli/references/alert.md index 72efe505e..efeb30c27 100644 --- a/packages/cli/plugins/sentry-cli/skills/sentry-cli/references/alert.md +++ b/packages/cli/plugins/sentry-cli/skills/sentry-cli/references/alert.md @@ -154,8 +154,8 @@ Create a metric alert rule **Flags:** - `--name - Rule name` - `--query - Metric query filter string` -- `--aggregate - Aggregate expression (for example count(), p95(transaction.duration))` -- `--dataset - Dataset: errors (error-events), transactions (transaction-like), sessions, events, spans, metrics` +- `--aggregate - Aggregate expression (for example count(), p95(span.duration))` +- `--dataset - Dataset: errors (error-events), sessions, events, spans, metrics` - `--time-window - Evaluation window in minutes` - `-t, --trigger ... - Trigger object JSON (repeatable, or pass one JSON array)` - `-p, --project ... - Project slug filter (repeatable or comma-separated)` @@ -170,8 +170,8 @@ Create a metric alert rule sentry alert metrics create my-org \ --name "P95 Latency" \ --query "environment:prod" \ - --aggregate "p95(transaction.duration)" \ - --dataset transactions \ + --aggregate "p95(span.duration)" \ + --dataset spans \ --time-window 5 \ --trigger '{"alertThreshold":500,"actions":[{"id":"sentry.mail.actions.NotifyEmailAction","targetType":"Team","targetIdentifier":1}]}' ``` @@ -201,7 +201,7 @@ Edit a metric alert rule - `--status - active or disabled` - `--query - Metric query filter` - `--aggregate - Aggregate expression` -- `--dataset - Dataset: errors (error-events), transactions (transaction-like), sessions, events, spans, metrics` +- `--dataset - Dataset: errors (error-events), sessions, events, spans, metrics` - `--time-window - Evaluation window in minutes` - `-t, --trigger ... - Trigger object JSON (repeatable, or pass one JSON array)` - `-p, --project ... - Project slug filter (repeatable or comma-separated)` diff --git a/packages/cli/src/commands/alert/metrics/create.ts b/packages/cli/src/commands/alert/metrics/create.ts index f46c65e88..933dee265 100644 --- a/packages/cli/src/commands/alert/metrics/create.ts +++ b/packages/cli/src/commands/alert/metrics/create.ts @@ -85,8 +85,8 @@ export const createCommand = buildCommand({ " --environment, --owner\n\n" + "Examples:\n" + " sentry alert metrics create my-org --name 'P95 latency' \\\n" + - " --query 'environment:prod' --aggregate 'p95(transaction.duration)' \\\n" + - " --dataset transactions --time-window 5 \\\n" + + " --query 'environment:prod' --aggregate 'p95(span.duration)' \\\n" + + " --dataset spans --time-window 5 \\\n" + ' --trigger \'{"alertThreshold":500,"actions":[{"id":"sentry.mail.actions.NotifyEmailAction","targetType":"Team","targetIdentifier":1}]}\'\n\n' + " sentry alert metrics create my-org --name 'Error volume' \\\n" + " --query 'event.type:error' --aggregate 'count()' --dataset errors \\\n" + @@ -122,14 +122,13 @@ export const createCommand = buildCommand({ aggregate: { kind: "parsed", parse: String, - brief: - "Aggregate expression (for example count(), p95(transaction.duration))", + brief: "Aggregate expression (for example count(), p95(span.duration))", }, dataset: { kind: "parsed", parse: String, brief: - "Dataset: errors (error-events), transactions (transaction-like), sessions, events, spans, metrics", + "Dataset: errors (error-events), sessions, events, spans, metrics", }, "time-window": { kind: "parsed", diff --git a/packages/cli/src/commands/alert/metrics/edit.ts b/packages/cli/src/commands/alert/metrics/edit.ts index 23c1136e8..0d6637f5b 100644 --- a/packages/cli/src/commands/alert/metrics/edit.ts +++ b/packages/cli/src/commands/alert/metrics/edit.ts @@ -166,7 +166,7 @@ export const editCommand = buildCommand({ "Examples:\n" + " sentry alert metrics edit my-org/9 --name 'Error budget'\n" + " sentry alert metrics edit my-org/9 --status disabled\n" + - " sentry alert metrics edit my-org/9 --time-window 15 --dataset transactions", + " sentry alert metrics edit my-org/9 --time-window 15 --dataset spans", }, output: { human: formatEdited, @@ -213,7 +213,7 @@ export const editCommand = buildCommand({ parse: String, optional: true, brief: - "Dataset: errors (error-events), transactions (transaction-like), sessions, events, spans, metrics", + "Dataset: errors (error-events), sessions, events, spans, metrics", }, "time-window": { kind: "parsed", diff --git a/packages/cli/src/commands/alert/mutation-utils.ts b/packages/cli/src/commands/alert/mutation-utils.ts index f800a9206..f4742c425 100644 --- a/packages/cli/src/commands/alert/mutation-utils.ts +++ b/packages/cli/src/commands/alert/mutation-utils.ts @@ -7,7 +7,6 @@ import { ValidationError } from "../../lib/errors.js"; const ISSUE_MATCH_MODES = new Set(["all", "any"]); const METRIC_DATASET_VALUES = new Set([ "errors", - "transactions", "sessions", "events", "spans", @@ -19,9 +18,9 @@ const METRIC_DATASET_VALUES = new Set([ * * Only aliases that resolve to a value already accepted by the metric alert API * are listed here: the singular forms (`error` → `errors`) and the dashboard - * terminology for the error/transaction datasets (`error-events` → `errors`, - * `transaction-like` → `transactions`). This lets users copying from dashboard - * docs avoid a validation error without changing which dataset is sent. + * terminology for the error dataset (`error-events` → `errors`). This lets + * users copying from dashboard docs avoid a validation error without + * changing which dataset is sent. * * Names that denote a *distinct* dataset in the metric alert path — e.g. * `tracemetrics`, `metricsenhanced`, `eap`, `events_analytics_platform` — are @@ -33,12 +32,10 @@ const METRIC_DATASET_VALUES = new Set([ const METRIC_DATASET_ALIASES: Record = { // Singular forms error: "errors", - transaction: "transactions", session: "sessions", metric: "metrics", - // Dashboard terminology for the error/transaction datasets + // Dashboard terminology for the error dataset "error-events": "errors", - "transaction-like": "transactions", }; const METRIC_TIME_WINDOWS = new Set([ 1, 5, 10, 15, 30, 60, 120, 240, 360, 720, 1440, @@ -203,9 +200,9 @@ export function normalizeProjectList( * Normalise a user-provided `--dataset` value to the canonical metric alert * dataset name accepted by the Sentry API. * - * Resolves known aliases (e.g. `error-events` → `errors`, `transaction` → - * `transactions`) so that values copied from dashboard docs or using singular - * forms work without manual translation. + * Resolves known aliases (e.g. `error-events` → `errors`) so that values copied + * from dashboard docs or using singular forms work without manual + * translation. */ export function normalizeMetricDataset(dataset: string): string { const lower = dataset.trim().toLowerCase(); diff --git a/packages/cli/test/commands/alert/metrics/edit.test.ts b/packages/cli/test/commands/alert/metrics/edit.test.ts index f03cf7811..c409304c2 100644 --- a/packages/cli/test/commands/alert/metrics/edit.test.ts +++ b/packages/cli/test/commands/alert/metrics/edit.test.ts @@ -98,7 +98,7 @@ describe("alert metrics edit", () => { status: 1, query: "event.type:error environment:prod", aggregate: "count()", - dataset: "transactions", + dataset: "spans", timeWindow: 15, triggers: [{ alertThreshold: 200, actions: [{ id: "notify" }] }], }); @@ -114,7 +114,7 @@ describe("alert metrics edit", () => { status: "disabled", query: "event.type:error environment:prod", aggregate: "count()", - dataset: "transactions", + dataset: "spans", "time-window": 15, trigger: ['{"alertThreshold":200,"actions":[{"id":"notify"}]}'], json: true, @@ -128,7 +128,7 @@ describe("alert metrics edit", () => { status: 1, query: "event.type:error environment:prod", aggregate: "count()", - dataset: "transactions", + dataset: "spans", timeWindow: 15, triggers: [{ alertThreshold: 200, actions: [{ id: "notify" }] }], }); diff --git a/packages/cli/test/commands/alert/mutation-utils.test.ts b/packages/cli/test/commands/alert/mutation-utils.test.ts index 86a29a112..e92f1d14c 100644 --- a/packages/cli/test/commands/alert/mutation-utils.test.ts +++ b/packages/cli/test/commands/alert/mutation-utils.test.ts @@ -212,23 +212,20 @@ describe("normalizeProjectList", () => { describe("normalizeMetricDataset", () => { test.each([ ["error", "errors"], - ["transaction", "transactions"], ["session", "sessions"], ["metric", "metrics"], ["error-events", "errors"], - ["transaction-like", "transactions"], ])('maps alias "%s" to "%s"', (input, expected) => { expect(normalizeMetricDataset(input)).toBe(expected); }); test("is case-insensitive and trims whitespace", () => { expect(normalizeMetricDataset("ERROR-EVENTS")).toBe("errors"); - expect(normalizeMetricDataset(" Transaction-Like ")).toBe("transactions"); + expect(normalizeMetricDataset(" Error-Events ")).toBe("errors"); }); test.each([ "errors", - "transactions", "sessions", "events", "spans", @@ -254,14 +251,7 @@ describe("normalizeMetricDataset", () => { }); describe("validateMetricDataset", () => { - const valid = [ - "errors", - "transactions", - "sessions", - "events", - "spans", - "metrics", - ]; + const valid = ["errors", "sessions", "events", "spans", "metrics"]; for (const dataset of valid) { test(`passes for "${dataset}"`, () => { @@ -272,7 +262,6 @@ describe("validateMetricDataset", () => { test.each([ "error", "error-events", - "transaction-like", "METRIC", ])('passes for alias "%s"', (dataset) => { expect(() => validateMetricDataset(dataset)).not.toThrow(); @@ -282,7 +271,9 @@ describe("validateMetricDataset", () => { "tracemetrics", "eap", "events_analytics_platform", - ])('throws for non-aliased dataset "%s"', (dataset) => { + "transactions", + "transaction-like", + ])('throws for obsolete or non-aliased dataset "%s"', (dataset) => { expect(() => validateMetricDataset(dataset)).toThrow(ValidationError); }); diff --git a/packages/cli/test/lib/api/alerts.test.ts b/packages/cli/test/lib/api/alerts.test.ts index 40a1e7646..5e42d82ca 100644 --- a/packages/cli/test/lib/api/alerts.test.ts +++ b/packages/cli/test/lib/api/alerts.test.ts @@ -130,8 +130,8 @@ function metricDetector(overrides: Record) { dateCreated: "2026-01-01T00:00:00Z", dataSources: [ { - aggregate: "p95(transaction.duration)", - dataset: "transactions", + aggregate: "p95(span.duration)", + dataset: "spans", query: "environment:prod", // Detectors expose the window in seconds; 300s == 5m. timeWindow: 300, @@ -159,8 +159,8 @@ describe("listMetricAlertsPaginated", () => { id: "9", name: "P95 latency", status: 0, - aggregate: "p95(transaction.duration)", - dataset: "transactions", + aggregate: "p95(span.duration)", + dataset: "spans", query: "environment:prod", // 300s from the detector payload is normalized to 5 minutes. timeWindow: 5, @@ -221,8 +221,8 @@ describe("getMetricAlertRule", () => { queryObj: { snubaQuery: { aggregate: "p75(measurements.lcp)", - dataset: "transactions", - query: "transaction.op:pageload", + dataset: "spans", + query: "span.op:pageload", timeWindow: 600, }, }, @@ -234,8 +234,8 @@ describe("getMetricAlertRule", () => { const rule = await getMetricAlertRule("test-org", "9"); expect(rule.aggregate).toBe("p75(measurements.lcp)"); - expect(rule.dataset).toBe("transactions"); - expect(rule.query).toBe("transaction.op:pageload"); + expect(rule.dataset).toBe("spans"); + expect(rule.query).toBe("span.op:pageload"); expect(rule.timeWindow).toBe(10); }); @@ -393,8 +393,8 @@ describe("createMetricAlertRule", () => { type: "metric_issue", dataSources: [ { - aggregate: "p95(transaction.duration)", - dataset: "transactions", + aggregate: "p95(span.duration)", + dataset: "spans", query: "environment:prod", queryType: 1, eventTypes: ["trace_item_span"], @@ -418,8 +418,8 @@ describe("createMetricAlertRule", () => { const created = await createMetricAlertRule("test-org", { name: "P95 latency", query: "environment:prod", - aggregate: "p95(transaction.duration)", - dataset: "transactions", + aggregate: "p95(span.duration)", + dataset: "spans", timeWindow: 5, environment: "prod", triggers: [{ alertThreshold: 500, actions: [{ id: "notify" }] }], @@ -480,8 +480,8 @@ describe("getMetricAlertRuleDocument", () => { expect(doc).toMatchObject({ id: "9", name: "Baseline", - aggregate: "p95(transaction.duration)", - dataset: "transactions", + aggregate: "p95(span.duration)", + dataset: "spans", timeWindow: 5, }); }); @@ -506,8 +506,8 @@ describe("putMetricAlertRule", () => { const updated = await putMetricAlertRule("test-org", "9", { name: "Renamed", query: "environment:prod", - aggregate: "p95(transaction.duration)", - dataset: "transactions", + aggregate: "p95(span.duration)", + dataset: "spans", timeWindow: 5, status: 1, triggers: [{ alertThreshold: 500, actions: [{ id: "notify" }] }],