From 7d49d5f33da1f0fb9af511b36392d811632a6587 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Fri, 8 Mar 2024 09:44:32 +0100 Subject: [PATCH 1/7] feat(metric-outcomes): Add initial topic and schema --- .../1/outcomes-metrics-full.json | 10 ++++ .../1/outcomes-metrics-only-cardinality.json | 8 +++ .../1/outcomes-metrics-only-volume.json | 8 +++ schemas/outcomes-metrics.v1.schema.json | 49 +++++++++++++++++++ topics/outcomes-metrics.yaml | 16 ++++++ 5 files changed, 91 insertions(+) create mode 100644 examples/outcomes-metrics/1/outcomes-metrics-full.json create mode 100644 examples/outcomes-metrics/1/outcomes-metrics-only-cardinality.json create mode 100644 examples/outcomes-metrics/1/outcomes-metrics-only-volume.json create mode 100644 schemas/outcomes-metrics.v1.schema.json create mode 100644 topics/outcomes-metrics.yaml diff --git a/examples/outcomes-metrics/1/outcomes-metrics-full.json b/examples/outcomes-metrics/1/outcomes-metrics-full.json new file mode 100644 index 00000000..f67cb613 --- /dev/null +++ b/examples/outcomes-metrics/1/outcomes-metrics-full.json @@ -0,0 +1,10 @@ +{ + "timestamp": 1709812800, + "org_id": 1, + "project_id": 1, + "mri": "d:custom/request_duration@seconds", + "outcome": 2, + "reason": "foobar", + "quantity": 42, + "cardinality": 1337 +} diff --git a/examples/outcomes-metrics/1/outcomes-metrics-only-cardinality.json b/examples/outcomes-metrics/1/outcomes-metrics-only-cardinality.json new file mode 100644 index 00000000..13f600dc --- /dev/null +++ b/examples/outcomes-metrics/1/outcomes-metrics-only-cardinality.json @@ -0,0 +1,8 @@ +{ + "timestamp": 1709812800, + "org_id": 1, + "project_id": 1, + "mri": "c:custom/clicks@none", + "outcome": 0, + "cardinality": 1337 +} diff --git a/examples/outcomes-metrics/1/outcomes-metrics-only-volume.json b/examples/outcomes-metrics/1/outcomes-metrics-only-volume.json new file mode 100644 index 00000000..9cb67f25 --- /dev/null +++ b/examples/outcomes-metrics/1/outcomes-metrics-only-volume.json @@ -0,0 +1,8 @@ +{ + "timestamp": 1709812800, + "org_id": 1, + "project_id": 1, + "mri": "c:custom/clicks@none", + "outcome": 0, + "quantity": 1337 +} diff --git a/schemas/outcomes-metrics.v1.schema.json b/schemas/outcomes-metrics.v1.schema.json new file mode 100644 index 00000000..33bd407b --- /dev/null +++ b/schemas/outcomes-metrics.v1.schema.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "metrics-outcome", + "$ref": "#/definitions/MetricsOutcome", + "definitions": { + "MetricsOutcome": { + "properties": { + "timestamp": { + "description": "The UNIX timestamp in seconds when the outcome was created, optionally truncated to the last hour.", + "$ref": "#/definitions/U64" + }, + "org_id": { + "description": "The organization for which this outcome is being sent.", + "$ref": "#/definitions/U64" + }, + "project_id": { + "description": "The project for which this outcome is being sent.", + "$ref": "#/definitions/U64" + }, + "mri": { + "description": "Valid metric resource identifier `:/[@]` for which the outcome is being sent.", + "type": "string" + }, + "outcome": { + "description": "Outcome ID, metric outcomes share the same numeric outcome ID with regular outcomes.", + "$ref": "#/definitions/U64" + }, + "reason": { + "description": "Optional machine readable, free-form reason code.", + "type": ["string", "null"] + }, + "quantity": { + "description": "Amount of metric buckets accepted by Relay (volume).", + "type": "integer" + }, + "cardinality": { + "description": "Maximum observed cardinality of the metric.", + "type": "integer" + } + }, + "required": ["timestamp", "org_id", "project_id", "mri", "outcome"] + }, + "U64": { + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + } + } +} diff --git a/topics/outcomes-metrics.yaml b/topics/outcomes-metrics.yaml new file mode 100644 index 00000000..0b62aab1 --- /dev/null +++ b/topics/outcomes-metrics.yaml @@ -0,0 +1,16 @@ +topic: outcomes-metrics +pipeline: outcomes +description: Outcomes for metrics sent to Sentry +services: + producers: + - getsentry/relay + consumers: + - getsentry/snuba + - getsentry/super-big-consumers +schemas: + - version: 1 + compatibility_mode: none + type: json + resource: outcomes-metrics.v1.schema.json + examples: + - outcomes-metrics/1 From 66f82809ad14ddf5c3e6e3fed1a2b28276d62a7f Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:50:42 +0000 Subject: [PATCH 2/7] style(lint): Auto commit lint changes --- topics/outcomes-metrics.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topics/outcomes-metrics.yaml b/topics/outcomes-metrics.yaml index 0b62aab1..373cde32 100644 --- a/topics/outcomes-metrics.yaml +++ b/topics/outcomes-metrics.yaml @@ -13,4 +13,4 @@ schemas: type: json resource: outcomes-metrics.v1.schema.json examples: - - outcomes-metrics/1 + - outcomes-metrics/1 From 3940fa83703c4195be653abb6c23b841cd66f451 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Fri, 8 Mar 2024 09:57:16 +0100 Subject: [PATCH 3/7] add missing code owners --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/CODEOWNERS b/CODEOWNERS index 242dd7d1..34396993 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -12,6 +12,7 @@ /topics/events.yaml @getsentry/owners-snuba /topics/transactions.yaml @getsentry/owners-snuba /topics/outcomes.yaml @getsentry/owners-snuba +/topics/outcomes-metrics.yaml @getsentry/owners-snuba @getsentry/ingest /topics/outcomes-billing.yaml @getsentry/owners-snuba /topics/snuba-metrics.yaml @getsentry/owners-snuba /topics/snuba-generic-metrics.yaml @getsentry/owners-snuba From 62a8094bc155863b15d2a6938807f5d38a1be341 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Fri, 8 Mar 2024 10:27:35 +0100 Subject: [PATCH 4/7] fix title --- schemas/outcomes-metrics.v1.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/outcomes-metrics.v1.schema.json b/schemas/outcomes-metrics.v1.schema.json index 33bd407b..e7d1ea55 100644 --- a/schemas/outcomes-metrics.v1.schema.json +++ b/schemas/outcomes-metrics.v1.schema.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "metrics-outcome", + "title": "metrics_outcome", "$ref": "#/definitions/MetricsOutcome", "definitions": { "MetricsOutcome": { From 4f093636f31df3ce17d34a8b05aa775e6caafa23 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Fri, 8 Mar 2024 10:35:34 +0100 Subject: [PATCH 5/7] type object --- schemas/outcomes-metrics.v1.schema.json | 1 + 1 file changed, 1 insertion(+) diff --git a/schemas/outcomes-metrics.v1.schema.json b/schemas/outcomes-metrics.v1.schema.json index e7d1ea55..6f00fc52 100644 --- a/schemas/outcomes-metrics.v1.schema.json +++ b/schemas/outcomes-metrics.v1.schema.json @@ -4,6 +4,7 @@ "$ref": "#/definitions/MetricsOutcome", "definitions": { "MetricsOutcome": { + "type": "object", "properties": { "timestamp": { "description": "The UNIX timestamp in seconds when the outcome was created, optionally truncated to the last hour.", From 6e753a21290819a741aeb1c0cffe1ed4c214fdb1 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Fri, 8 Mar 2024 15:08:40 +0100 Subject: [PATCH 6/7] use u64 type for quantity and cardinality --- schemas/outcomes-metrics.v1.schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/outcomes-metrics.v1.schema.json b/schemas/outcomes-metrics.v1.schema.json index 6f00fc52..b1673a01 100644 --- a/schemas/outcomes-metrics.v1.schema.json +++ b/schemas/outcomes-metrics.v1.schema.json @@ -32,11 +32,11 @@ }, "quantity": { "description": "Amount of metric buckets accepted by Relay (volume).", - "type": "integer" + "$ref": "#/definitions/U64" }, "cardinality": { "description": "Maximum observed cardinality of the metric.", - "type": "integer" + "$ref": "#/definitions/U64" } }, "required": ["timestamp", "org_id", "project_id", "mri", "outcome"] From ca37824fbe24a9a0998a54445d6624319f990596 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Mon, 11 Mar 2024 12:55:44 +0100 Subject: [PATCH 7/7] add cardinality_window --- schemas/outcomes-metrics.v1.schema.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/schemas/outcomes-metrics.v1.schema.json b/schemas/outcomes-metrics.v1.schema.json index b1673a01..7608fcdd 100644 --- a/schemas/outcomes-metrics.v1.schema.json +++ b/schemas/outcomes-metrics.v1.schema.json @@ -37,9 +37,18 @@ "cardinality": { "description": "Maximum observed cardinality of the metric.", "$ref": "#/definitions/U64" + }, + "cardinality_window": { + "description": "Time window, in seconds, in which the cardinality was observed.", + "$ref": "#/definitions/U64" } }, - "required": ["timestamp", "org_id", "project_id", "mri", "outcome"] + "required": ["timestamp", "org_id", "project_id", "mri", "outcome"], + "dependentSchemas": { + "cardinality": { + "required": ["cardinality_window"] + } + } }, "U64": { "type": "integer",