From 2f8196d365a8b8fda1a903b5c385e92e2f16ffc9 Mon Sep 17 00:00:00 2001 From: Joris Bayer Date: Tue, 4 Jun 2024 16:12:05 +0200 Subject: [PATCH 1/2] fix(spans): Do not trim timestamps --- relay-event-normalization/src/trimming.rs | 24 ++++++++++++++++++----- relay-event-schema/src/protocol/span.rs | 4 ++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/relay-event-normalization/src/trimming.rs b/relay-event-normalization/src/trimming.rs index c5bb4a9ee1..099c9fff41 100644 --- a/relay-event-normalization/src/trimming.rs +++ b/relay-event-normalization/src/trimming.rs @@ -413,9 +413,10 @@ fn slim_frame_data(frames: &mut Array, frame_allowance: usize) { mod tests { use std::iter::repeat; + use chrono::DateTime; use relay_event_schema::protocol::{ Breadcrumb, Context, Contexts, Event, Exception, ExtraValue, Span, SpanId, TagEntry, Tags, - TraceId, Values, + Timestamp, TraceId, Values, }; use relay_protocol::{get_value, Map, Remark, SerializableAnnotated}; use similar_asserts::assert_eq; @@ -954,7 +955,7 @@ mod tests { } #[test] - fn test_too_many_spans_trimmed_trace_id() { + fn test_untrimmable_fields() { let original_description = "a".repeat(819163); let original_trace_id = TraceId("b".repeat(48)); let mut event = Annotated::new(Event { @@ -985,8 +986,8 @@ mod tests { } #[test] - fn test_too_many_spans_trimmed_trace_id_drop() { - let original_description = "a".repeat(819163); + fn test_untrimmable_fields_drop() { + let original_description = "a".repeat(819164); let original_span_id = SpanId("b".repeat(48)); let original_trace_id = TraceId("c".repeat(48)); let original_segment_id = SpanId("d".repeat(48)); @@ -1005,6 +1006,18 @@ mod tests { segment_id: original_segment_id.clone().into(), is_segment: false.into(), op: original_op.clone().into(), + start_timestamp: Timestamp( + DateTime::parse_from_rfc3339("1996-12-19T16:39:57Z") + .unwrap() + .into(), + ) + .into(), + timestamp: Timestamp( + DateTime::parse_from_rfc3339("1996-12-19T16:39:58Z") + .unwrap() + .into(), + ) + .into(), ..Default::default() } .into(), @@ -1024,9 +1037,10 @@ mod tests { assert_eq!(get_value!(event.spans[1].trace_id!), &original_trace_id); assert_eq!(get_value!(event.spans[1].segment_id!), &original_segment_id); assert_eq!(get_value!(event.spans[1].is_segment!), &false); - // span.op is trimmed to its max_chars, but not dropped: assert_eq!(get_value!(event.spans[1].op!).len(), 128); + assert!(dbg!(get_value!(event.spans[1].start_timestamp)).is_some()); + assert!(get_value!(event.spans[1].timestamp).is_some()); } #[test] diff --git a/relay-event-schema/src/protocol/span.rs b/relay-event-schema/src/protocol/span.rs index 933d71f06d..3b7808d58b 100644 --- a/relay-event-schema/src/protocol/span.rs +++ b/relay-event-schema/src/protocol/span.rs @@ -15,11 +15,11 @@ use crate::protocol::{ #[metastructure(process_func = "process_span", value_type = "Span")] pub struct Span { /// Timestamp when the span was ended. - #[metastructure(required = "true")] + #[metastructure(required = "true", trim = "false")] pub timestamp: Annotated, /// Timestamp when the span started. - #[metastructure(required = "true")] + #[metastructure(required = "true", trim = "false")] pub start_timestamp: Annotated, /// The amount of time in milliseconds spent in this span, From d5a8a31df3df6cc4be4b6cc689f348102b686763 Mon Sep 17 00:00:00 2001 From: Joris Bayer Date: Tue, 4 Jun 2024 16:13:50 +0200 Subject: [PATCH 2/2] rm dbg --- relay-event-normalization/src/trimming.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relay-event-normalization/src/trimming.rs b/relay-event-normalization/src/trimming.rs index 099c9fff41..c947436022 100644 --- a/relay-event-normalization/src/trimming.rs +++ b/relay-event-normalization/src/trimming.rs @@ -1039,7 +1039,7 @@ mod tests { assert_eq!(get_value!(event.spans[1].is_segment!), &false); // span.op is trimmed to its max_chars, but not dropped: assert_eq!(get_value!(event.spans[1].op!).len(), 128); - assert!(dbg!(get_value!(event.spans[1].start_timestamp)).is_some()); + assert!(get_value!(event.spans[1].start_timestamp).is_some()); assert!(get_value!(event.spans[1].timestamp).is_some()); }