From fec0f03067beedd0d80618942387f9af585baeb2 Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 08:57:20 -0700 Subject: [PATCH 01/15] feat(monitors): Add trace context to CheckIns --- relay-monitors/src/lib.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index a5b556c4cc..3103c901ce 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -19,6 +19,8 @@ use relay_common::Uuid; use serde::{Deserialize, Serialize}; +use crate::protocol::Contexts; + /// Maximum length of monitor slugs. const SLUG_LENGTH: usize = 50; @@ -77,7 +79,7 @@ enum IntervalName { Minute, } -/// The monitor configuration playload for upserting monitors during check-in +/// The monitor configuration payload for upserting monitors during check-in #[derive(Debug, Deserialize, Serialize)] pub struct MonitorConfig { /// The monitor schedule configuration @@ -122,6 +124,11 @@ pub struct CheckIn { /// monitor configuration to support upserts. #[serde(default, skip_serializing_if = "Option::is_none")] pub monitor_config: Option, + + /// Contexts describing the environment (e.g. device, os or browser). + #[metastructure(legacy_alias = "sentry.interfaces.Contexts")] + #[metastructure(skip_serialization = "empty")] + pub contexts: Annotated, } /// Normalizes a monitor check-in payload. @@ -172,7 +179,13 @@ mod tests { "monitor_slug": "my-monitor", "status": "in_progress", "environment": "production", - "duration": 21.0 + "duration": 21.0, + "contexts": { + "trace": { + "trace_id": "8f431b7aa08441bbbd5a0100fd91f9fe", + "span_id": "bb8f278130535c3c", + } + } }"#; let check_in = serde_json::from_str::(json).unwrap(); From 040d827bf13bb2cef6eca79363327977f6e9e38c Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 09:00:42 -0700 Subject: [PATCH 02/15] added changelog --- py/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/py/CHANGELOG.md b/py/CHANGELOG.md index 867749789a..9c30b954f5 100644 --- a/py/CHANGELOG.md +++ b/py/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Add `lock` attribute to the frame protocol. ([#2171](https://github.com/getsentry/relay/pull/2171)) +- Add trace context to CheckIns. ([#2241](https://github.com/getsentry/relay/pull/2241)) ## 0.8.25 From 41663c2e9a0fd90c7c1c98a281954796db23bb31 Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 09:11:22 -0700 Subject: [PATCH 03/15] added import --- relay-monitors/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index 3103c901ce..a878d857e8 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -21,6 +21,8 @@ use serde::{Deserialize, Serialize}; use crate::protocol::Contexts; +use crate::types::Annotated; + /// Maximum length of monitor slugs. const SLUG_LENGTH: usize = 50; From 36dd15e20206d854cac1b419d9dae064dbc231b9 Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 09:17:00 -0700 Subject: [PATCH 04/15] fixed imports --- relay-monitors/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index a878d857e8..65ce8d1643 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -17,12 +17,10 @@ #![warn(missing_docs)] use relay_common::Uuid; +use relay_general::protocol::Contexts; +use relay_general::types::Annotated; use serde::{Deserialize, Serialize}; -use crate::protocol::Contexts; - -use crate::types::Annotated; - /// Maximum length of monitor slugs. const SLUG_LENGTH: usize = 50; From eb9cb3e315296950c925153784bf532e14ba0126 Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 09:23:46 -0700 Subject: [PATCH 05/15] better imports --- relay-monitors/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/relay-monitors/Cargo.toml b/relay-monitors/Cargo.toml index 06264d9ab7..6ca95d856a 100644 --- a/relay-monitors/Cargo.toml +++ b/relay-monitors/Cargo.toml @@ -11,6 +11,7 @@ publish = false [dependencies] relay-common = { path = "../relay-common" } +relay-general = { path = "../relay-general" } serde = { version = "1.0.114", features = ["derive"] } serde_json = "1.0.55" regex = "1.5.5" From 684c70a7ae2bc9b872687d6a54a5c4b2b69e1c92 Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 09:31:47 -0700 Subject: [PATCH 06/15] changed types --- relay-monitors/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index 65ce8d1643..b7f3b14c95 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -18,7 +18,6 @@ use relay_common::Uuid; use relay_general::protocol::Contexts; -use relay_general::types::Annotated; use serde::{Deserialize, Serialize}; /// Maximum length of monitor slugs. @@ -126,9 +125,8 @@ pub struct CheckIn { pub monitor_config: Option, /// Contexts describing the environment (e.g. device, os or browser). - #[metastructure(legacy_alias = "sentry.interfaces.Contexts")] - #[metastructure(skip_serialization = "empty")] - pub contexts: Annotated, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub contexts: Option, } /// Normalizes a monitor check-in payload. From 93ca91e92a77f78e13dce63d162193d386baea30 Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 10:55:14 -0700 Subject: [PATCH 07/15] spec contexts explicitly --- relay-monitors/Cargo.toml | 1 - relay-monitors/src/lib.rs | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/relay-monitors/Cargo.toml b/relay-monitors/Cargo.toml index 6ca95d856a..06264d9ab7 100644 --- a/relay-monitors/Cargo.toml +++ b/relay-monitors/Cargo.toml @@ -11,7 +11,6 @@ publish = false [dependencies] relay-common = { path = "../relay-common" } -relay-general = { path = "../relay-general" } serde = { version = "1.0.114", features = ["derive"] } serde_json = "1.0.55" regex = "1.5.5" diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index b7f3b14c95..34f1389756 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -99,6 +99,22 @@ pub struct MonitorConfig { timezone: Option, } +/// The trace context sent with a check-in +#[derive(Debug, Deserialize, Serialize)] +pub struct CheckInTrace { + /// How long (in minutes) after the expected checkin time will we wait until we consider the + /// checkin to have been missed. + #[serde(serialize_with = "uuid_simple")] + trace_id: Uuid, +} + +/// Any contexts sent in the check-in payload +#[derive(Debug, Deserialize, Serialize)] +pub struct CheckInContexts { + #[serde(default, skip_serializing_if = "Option::is_none")] + trace: Option, +} + /// The monitor check-in payload. #[derive(Debug, Deserialize, Serialize)] pub struct CheckIn { @@ -126,7 +142,7 @@ pub struct CheckIn { /// Contexts describing the environment (e.g. device, os or browser). #[serde(default, skip_serializing_if = "Option::is_none")] - pub contexts: Option, + pub contexts: Option, } /// Normalizes a monitor check-in payload. From d5bc52279d6ff6e44aab47e2f99cf59739a42f7d Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 11:02:53 -0700 Subject: [PATCH 08/15] fix imports --- relay-monitors/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index 34f1389756..c95fa20513 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -17,7 +17,6 @@ #![warn(missing_docs)] use relay_common::Uuid; -use relay_general::protocol::Contexts; use serde::{Deserialize, Serialize}; /// Maximum length of monitor slugs. @@ -197,7 +196,6 @@ mod tests { "contexts": { "trace": { "trace_id": "8f431b7aa08441bbbd5a0100fd91f9fe", - "span_id": "bb8f278130535c3c", } } }"#; From aa0f0189cde7805f8643bdc2ead5b43726f4f5c5 Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 11:12:03 -0700 Subject: [PATCH 09/15] add to params --- relay-server/src/endpoints/cron.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/relay-server/src/endpoints/cron.rs b/relay-server/src/endpoints/cron.rs index 21fc002933..456a6e3af8 100644 --- a/relay-server/src/endpoints/cron.rs +++ b/relay-server/src/endpoints/cron.rs @@ -51,6 +51,7 @@ impl CronParams { environment: query.environment, duration: query.duration, monitor_config: None, + contexts: None, }) .map_err(BadStoreRequest::InvalidJson)?, ); From 0a252e7d3885f87128985b824331ca12a70bd4eb Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 11:23:54 -0700 Subject: [PATCH 10/15] remove trailing comma --- relay-monitors/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index c95fa20513..aaacc5e03a 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -195,7 +195,7 @@ mod tests { "duration": 21.0, "contexts": { "trace": { - "trace_id": "8f431b7aa08441bbbd5a0100fd91f9fe", + "trace_id": "8f431b7aa08441bbbd5a0100fd91f9fe" } } }"#; From 4dfc1dc3b8f171d4ff4af67af8b0e7c0dd216b5d Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 11:32:50 -0700 Subject: [PATCH 11/15] fixed spacing --- relay-monitors/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index aaacc5e03a..3d656a2a90 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -195,7 +195,7 @@ mod tests { "duration": 21.0, "contexts": { "trace": { - "trace_id": "8f431b7aa08441bbbd5a0100fd91f9fe" + "trace_id": "8f431b7aa08441bbbd5a0100fd91f9fe" } } }"#; From 44fa152c8d3eb0ebdc71fc6a8c25b9562e06cf6b Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 11:52:34 -0700 Subject: [PATCH 12/15] fixed comment --- relay-monitors/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index 3d656a2a90..e896bef667 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -101,8 +101,7 @@ pub struct MonitorConfig { /// The trace context sent with a check-in #[derive(Debug, Deserialize, Serialize)] pub struct CheckInTrace { - /// How long (in minutes) after the expected checkin time will we wait until we consider the - /// checkin to have been missed. + /// trace id of the check-in #[serde(serialize_with = "uuid_simple")] trace_id: Uuid, } @@ -110,6 +109,7 @@ pub struct CheckInTrace { /// Any contexts sent in the check-in payload #[derive(Debug, Deserialize, Serialize)] pub struct CheckInContexts { + /// Trace context sent with a check-n #[serde(default, skip_serializing_if = "Option::is_none")] trace: Option, } From bfa65b0438ceec76c83b719955420c434b658e33 Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Thu, 22 Jun 2023 11:53:59 -0700 Subject: [PATCH 13/15] more comments --- relay-monitors/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index e896bef667..eb007a72ab 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -98,7 +98,7 @@ pub struct MonitorConfig { timezone: Option, } -/// The trace context sent with a check-in +/// The trace context sent with a check-in. #[derive(Debug, Deserialize, Serialize)] pub struct CheckInTrace { /// trace id of the check-in @@ -106,10 +106,10 @@ pub struct CheckInTrace { trace_id: Uuid, } -/// Any contexts sent in the check-in payload +/// Any contexts sent in the check-in payload. #[derive(Debug, Deserialize, Serialize)] pub struct CheckInContexts { - /// Trace context sent with a check-n + /// Trace context sent with a check-in. #[serde(default, skip_serializing_if = "Option::is_none")] trace: Option, } @@ -139,7 +139,8 @@ pub struct CheckIn { #[serde(default, skip_serializing_if = "Option::is_none")] pub monitor_config: Option, - /// Contexts describing the environment (e.g. device, os or browser). + /// Contexts describing the associated environment of the job run. + /// Only supports trace for now #[serde(default, skip_serializing_if = "Option::is_none")] pub contexts: Option, } From d16fe2b91a96384a44a226ef5e449143a1948bfc Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Fri, 23 Jun 2023 08:40:25 -0700 Subject: [PATCH 14/15] Update relay-monitors/src/lib.rs Co-authored-by: Joris Bayer --- relay-monitors/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index eb007a72ab..e152574d92 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -140,7 +140,7 @@ pub struct CheckIn { pub monitor_config: Option, /// Contexts describing the associated environment of the job run. - /// Only supports trace for now + /// Only supports trace for now. #[serde(default, skip_serializing_if = "Option::is_none")] pub contexts: Option, } From 254da8ff1412fa450c898718742858dcb9d4b2ac Mon Sep 17 00:00:00 2001 From: Richard Ortenberg Date: Fri, 23 Jun 2023 08:40:32 -0700 Subject: [PATCH 15/15] Update relay-monitors/src/lib.rs Co-authored-by: Joris Bayer --- relay-monitors/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index e152574d92..824ffb9702 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -101,7 +101,7 @@ pub struct MonitorConfig { /// The trace context sent with a check-in. #[derive(Debug, Deserialize, Serialize)] pub struct CheckInTrace { - /// trace id of the check-in + /// Trace-ID of the check-in. #[serde(serialize_with = "uuid_simple")] trace_id: Uuid, }