Skip to content

Commit

Permalink
fix(spans): Do not trim timestamps (#3686)
Browse files Browse the repository at this point in the history
Follow-up to #3670: Also stop
trimming span timestamps.
  • Loading branch information
jjbayer authored Jun 5, 2024
1 parent 60a76c7 commit c227ece
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
24 changes: 19 additions & 5 deletions relay-event-normalization/src/trimming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,10 @@ fn slim_frame_data(frames: &mut Array<Frame>, 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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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));
Expand All @@ -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(),
Expand All @@ -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!(get_value!(event.spans[1].start_timestamp).is_some());
assert!(get_value!(event.spans[1].timestamp).is_some());
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions relay-event-schema/src/protocol/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,

/// Timestamp when the span started.
#[metastructure(required = "true")]
#[metastructure(required = "true", trim = "false")]
pub start_timestamp: Annotated<Timestamp>,

/// The amount of time in milliseconds spent in this span,
Expand Down

0 comments on commit c227ece

Please sign in to comment.