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 diff --git a/relay-monitors/src/lib.rs b/relay-monitors/src/lib.rs index a5b556c4cc..824ffb9702 100644 --- a/relay-monitors/src/lib.rs +++ b/relay-monitors/src/lib.rs @@ -77,7 +77,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 @@ -98,6 +98,22 @@ pub struct MonitorConfig { timezone: Option, } +/// The trace context sent with a check-in. +#[derive(Debug, Deserialize, Serialize)] +pub struct CheckInTrace { + /// Trace-ID of the check-in. + #[serde(serialize_with = "uuid_simple")] + trace_id: Uuid, +} + +/// Any contexts sent in the check-in payload. +#[derive(Debug, Deserialize, Serialize)] +pub struct CheckInContexts { + /// Trace context sent with a check-in. + #[serde(default, skip_serializing_if = "Option::is_none")] + trace: Option, +} + /// The monitor check-in payload. #[derive(Debug, Deserialize, Serialize)] pub struct CheckIn { @@ -122,6 +138,11 @@ pub struct CheckIn { /// monitor configuration to support upserts. #[serde(default, skip_serializing_if = "Option::is_none")] pub monitor_config: Option, + + /// 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, } /// Normalizes a monitor check-in payload. @@ -172,7 +193,12 @@ mod tests { "monitor_slug": "my-monitor", "status": "in_progress", "environment": "production", - "duration": 21.0 + "duration": 21.0, + "contexts": { + "trace": { + "trace_id": "8f431b7aa08441bbbd5a0100fd91f9fe" + } + } }"#; let check_in = serde_json::from_str::(json).unwrap(); 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)?, );