Skip to content

Commit cf6e06a

Browse files
authored
test(spans): Snapshot for span backfill (#5093)
Just a snapshot test that can be used as input for the conversion test in sentry. ref: INGEST-528
1 parent 44f34dc commit cf6e06a

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed

relay-server/src/services/store.rs

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,7 @@ fn safe_timestamp(timestamp: DateTime<Utc>) -> u64 {
20082008

20092009
#[cfg(test)]
20102010
mod tests {
2011+
20112012
use super::*;
20122013

20132014
#[test]
@@ -2023,4 +2024,134 @@ mod tests {
20232024
assert!(matches!(res, Err(ClientError::InvalidTopicName)));
20242025
}
20252026
}
2027+
2028+
#[test]
2029+
fn backfill() {
2030+
let json = r#"{
2031+
"description": "/api/0/relays/projectconfigs/",
2032+
"duration_ms": 152,
2033+
"exclusive_time": 0.228,
2034+
"is_segment": true,
2035+
"data": {
2036+
"sentry.environment": "development",
2037+
"sentry.release": "[email protected]+c45b49caed1e5fcbf70097ab3f434b487c359b6b",
2038+
"thread.name": "uWSGIWorker1Core0",
2039+
"thread.id": "8522009600",
2040+
"sentry.segment.name": "/api/0/relays/projectconfigs/",
2041+
"sentry.sdk.name": "sentry.python.django",
2042+
"sentry.sdk.version": "2.7.0",
2043+
"my.float.field": 101.2,
2044+
"my.int.field": 2000,
2045+
"my.neg.field": -100,
2046+
"my.neg.float.field": -101.2,
2047+
"my.true.bool.field": true,
2048+
"my.false.bool.field": false,
2049+
"my.dict.field": {
2050+
"id": 42,
2051+
"name": "test"
2052+
},
2053+
"my.u64.field": 9447000002305251000,
2054+
"my.array.field": [1, 2, ["nested", "array"]]
2055+
},
2056+
"measurements": {
2057+
"num_of_spans": {"value": 50.0},
2058+
"client_sample_rate": {"value": 0.1},
2059+
"server_sample_rate": {"value": 0.2}
2060+
},
2061+
"profile_id": "56c7d1401ea14ad7b4ac86de46baebae",
2062+
"organization_id": 1,
2063+
"origin": "auto.http.django",
2064+
"project_id": 1,
2065+
"received": 1721319572.877828,
2066+
"retention_days": 90,
2067+
"segment_id": "8873a98879faf06d",
2068+
"sentry_tags": {
2069+
"description": "normalized_description",
2070+
"category": "http",
2071+
"environment": "development",
2072+
"op": "http.server",
2073+
"platform": "python",
2074+
"release": "[email protected]+c45b49caed1e5fcbf70097ab3f434b487c359b6b",
2075+
"sdk.name": "sentry.python.django",
2076+
"sdk.version": "2.7.0",
2077+
"status": "ok",
2078+
"status_code": "200",
2079+
"thread.id": "8522009600",
2080+
"thread.name": "uWSGIWorker1Core0",
2081+
"trace.status": "ok",
2082+
"transaction": "/api/0/relays/projectconfigs/",
2083+
"transaction.method": "POST",
2084+
"transaction.op": "http.server",
2085+
"user": "ip:127.0.0.1"
2086+
},
2087+
"span_id": "8873a98879faf06d",
2088+
"tags": {
2089+
"http.status_code": "200",
2090+
"relay_endpoint_version": "3",
2091+
"relay_id": "88888888-4444-4444-8444-cccccccccccc",
2092+
"relay_no_cache": "False",
2093+
"relay_protocol_version": "3",
2094+
"relay_use_post_or_schedule": "True",
2095+
"relay_use_post_or_schedule_rejected": "version",
2096+
"server_name": "D23CXQ4GK2.local",
2097+
"spans_over_limit": "False"
2098+
},
2099+
"trace_id": "d099bf9ad5a143cf8f83a98081d0ed3b",
2100+
"start_timestamp_ms": 1721319572616,
2101+
"start_timestamp": 1721319572.616648,
2102+
"timestamp": 1721319572.768806
2103+
}"#;
2104+
let mut span: SpanKafkaMessage = serde_json::from_str(json).unwrap();
2105+
span.backfill_data();
2106+
2107+
assert_eq!(
2108+
serde_json::to_string_pretty(&span.data).unwrap(),
2109+
r#"{
2110+
"http.status_code": "200",
2111+
"my.array.field": [1, 2, ["nested", "array"]],
2112+
"my.dict.field": {
2113+
"id": 42,
2114+
"name": "test"
2115+
},
2116+
"my.false.bool.field": false,
2117+
"my.float.field": 101.2,
2118+
"my.int.field": 2000,
2119+
"my.neg.field": -100,
2120+
"my.neg.float.field": -101.2,
2121+
"my.true.bool.field": true,
2122+
"my.u64.field": 9447000002305251000,
2123+
"num_of_spans": 50.0,
2124+
"relay_endpoint_version": "3",
2125+
"relay_id": "88888888-4444-4444-8444-cccccccccccc",
2126+
"relay_no_cache": "False",
2127+
"relay_protocol_version": "3",
2128+
"relay_use_post_or_schedule": "True",
2129+
"relay_use_post_or_schedule_rejected": "version",
2130+
"sentry.category": "http",
2131+
"sentry.client_sample_rate": 0.1,
2132+
"sentry.environment": "development",
2133+
"sentry.normalized_description": "normalized_description",
2134+
"sentry.op": "http.server",
2135+
"sentry.platform": "python",
2136+
"sentry.release": "[email protected]+c45b49caed1e5fcbf70097ab3f434b487c359b6b",
2137+
"sentry.sdk.name": "sentry.python.django",
2138+
"sentry.sdk.version": "2.7.0",
2139+
"sentry.segment.name": "/api/0/relays/projectconfigs/",
2140+
"sentry.server_sample_rate": 0.2,
2141+
"sentry.status": "ok",
2142+
"sentry.status_code": "200",
2143+
"sentry.thread.id": "8522009600",
2144+
"sentry.thread.name": "uWSGIWorker1Core0",
2145+
"sentry.trace.status": "ok",
2146+
"sentry.transaction": "/api/0/relays/projectconfigs/",
2147+
"sentry.transaction.method": "POST",
2148+
"sentry.transaction.op": "http.server",
2149+
"sentry.user": "ip:127.0.0.1",
2150+
"server_name": "D23CXQ4GK2.local",
2151+
"spans_over_limit": "False",
2152+
"thread.id": "8522009600",
2153+
"thread.name": "uWSGIWorker1Core0"
2154+
}"#
2155+
);
2156+
}
20262157
}

0 commit comments

Comments
 (0)