-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix(trace-utils): v05 events and span links serialization #980
base: main
Are you sure you want to change the base?
Conversation
BenchmarksComparisonBenchmark execution time: 2025-03-27 14:59:30 Comparing candidate commit 798fba6 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 52 metrics, 2 unstable metrics. CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
BaselineOmitted due to size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of comments. Additionally it'd be great to add spanlinks and spanevents support to v05 snapshots in data-pipeline/tests/ to have them covered.
if !span.span_links.is_empty() { | ||
let serialized_span_links = serde_json::to_string(&span.span_links)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should check here for the 25kb limit on the tag value, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, anything beyond 25KB limits is dropped. the implementation should try to stuff as many as links possible under the limit and drop the others.
There used to be dropped_attributes_count
to count the dropped attributes in case of oversized span links which i didn't see our implementation.
if !span.span_links.is_empty() { | ||
let serialized_span_links = serde_json::to_string(&span.span_links)?; | ||
meta.insert( | ||
dict.get_or_insert(&tinybytes::BytesString::from("span_links"))?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the RFC there is some discussion about "span_links" or "_dd.span_links". Did they finally choose the former?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's a mistake the key should definitely be "_dd.span_links" from other implementations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few minor comments around tests and one major around tag size limit
overall looks good.
///This structure is a wrapper around a slice of span events | ||
/// | ||
/// It is meant to overrdide the default serialization, so we can serialize attributes | ||
/// differently from the original impl. | ||
/// Span events are serialized to JSON and added to "meta" when serializing to v0.5 | ||
/// | ||
/// The main difference with messagepacck serialization is that attributes with any types | ||
/// are supposed to be mapped to their natural JSON representation. | ||
/// | ||
/// Sadly, I haven't found a good way of overriding the default Serialize behavior, other | ||
/// than just doing it for the whole data structures that embed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
///This structure is a wrapper around a slice of span events | |
/// | |
/// It is meant to overrdide the default serialization, so we can serialize attributes | |
/// differently from the original impl. | |
/// Span events are serialized to JSON and added to "meta" when serializing to v0.5 | |
/// | |
/// The main difference with messagepacck serialization is that attributes with any types | |
/// are supposed to be mapped to their natural JSON representation. | |
/// | |
/// Sadly, I haven't found a good way of overriding the default Serialize behavior, other | |
/// than just doing it for the whole data structures that embed it. | |
/// This structure is a wrapper around a slice of span events | |
/// | |
/// It is meant to override the default serialization, so we can serialize attributes | |
/// differently from the original impl. | |
/// Span events are serialized to JSON and added to "meta" when serializing to v0.5 | |
/// | |
/// The main difference with messagepack serialization is that attributes with any types | |
/// are supposed to be mapped to their natural JSON representation. |
you can skip the justification and personalization.
@@ -82,8 +209,47 @@ mod tests { | |||
)]), | |||
metrics: HashMap::from([(BytesString::from("metrics_field"), 1.1)]), | |||
meta_struct: HashMap::new(), | |||
span_links: vec![], | |||
span_events: vec![], | |||
span_links: vec![SpanLinkBytes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/suggestion
- would be nice to have test case for multiple span links
- a complex attributes (remember we do some flattening for array and maps), I'm not sure at this point we have them already or we have to do ourselves
eg
{"key": [[1,2], ["3", "4"]]} to {"key.0.0": "1", "key.0.1": 2, "key.1.0": 3, "key.1.1":4}
if !span.span_links.is_empty() { | ||
let serialized_span_links = serde_json::to_string(&span.span_links)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, anything beyond 25KB limits is dropped. the implementation should try to stuff as many as links possible under the limit and drop the others.
There used to be dropped_attributes_count
to count the dropped attributes in case of oversized span links which i didn't see our implementation.
What does this PR do?
V05 format specifies fallback options for serializing events and span links inside of the meta field.
span_links fallback format spec
event fallback format spec
This PR should be fixing it
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
How to test the change?
Describe here in detail how the change can be validated.