Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spans): Retain empty attributes #4174

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test
  • Loading branch information
jjbayer committed Oct 28, 2024
commit fa08a5925cd75042e1db9b34e05b27f0877142ef
24 changes: 22 additions & 2 deletions relay-event-schema/src/protocol/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ pub struct SpanData {
additional_properties,
pii = "true",
retain = "true",
skip_serialization = "null"
skip_serialization = "null" // applies to child elements
)]
pub other: Object<Value>,
}
Expand Down Expand Up @@ -933,7 +933,18 @@ mod tests {
}

#[test]
fn test_span_data_empty_field() {
fn test_span_data_empty_well_known_field() {
let span = r#"{
"data": {
"lcp.url": ""
}
}"#;
let span: Annotated<Span> = Annotated::from_json(span).unwrap();
assert_eq!(span.to_json().unwrap(), r#"{"data":{"lcp.url":""}}"#);
}

#[test]
fn test_span_data_empty_custom_field() {
let span = r#"{
"data": {
"custom_field_empty": ""
Expand All @@ -945,4 +956,13 @@ mod tests {
r#"{"data":{"custom_field_empty":""}}"#
);
}

#[test]
fn test_span_data_completely_empty() {
let span = r#"{
"data": {}
}"#;
let span: Annotated<Span> = Annotated::from_json(span).unwrap();
assert_eq!(span.to_json().unwrap(), r#"{"data":{}}"#);
}
Comment on lines +960 to +967
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that this test has the same result on master. skip_serialization applies to child elements, not the element itself.

}
Loading