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

[v2][adjuster] Implement adjuster for sorting attributes and events #6389

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

Which problem is this PR solving?

Description of the changes

  • Implemented an adjuster to sort attributes and events that operates natively on the OTLP data format. This is analogous to the SortTagsAndLogFields adjuster in v1.

How was this change tested?

  • Added a unit test

Checklist

for k := 0; k < spans.Len(); k++ {
span := spans.At(k)
s.sortAttributes(span.Attributes())
s.sortEvents(span.Events())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro Wanted a sanity check here. In v1, the "event" field was moved to the first position (ref: https://github.com/jaegertracing/jaeger/blob/main/model/adjuster/sort_tags_and_log_fields.go#L31). However, in v2, logs are stored as event attributes and the "event" attribute is stored as the event name (https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/translator/jaeger/jaegerproto_to_traces.go#L406).

Copy link
Member

Choose a reason for hiding this comment

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

sgtm. Good to have first class fields.

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.19%. Comparing base (5ab3d26) to head (573cd00).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6389      +/-   ##
==========================================
- Coverage   96.22%   96.19%   -0.03%     
==========================================
  Files         361      362       +1     
  Lines       20621    20671      +50     
==========================================
+ Hits        19843    19885      +42     
- Misses        595      601       +6     
- Partials      183      185       +2     
Flag Coverage Δ
badger_v1 9.05% <ø> (ø)
badger_v2 1.64% <ø> (ø)
cassandra-4.x-v1-manual 15.01% <ø> (ø)
cassandra-4.x-v2-auto 1.58% <ø> (ø)
cassandra-4.x-v2-manual 1.58% <ø> (ø)
cassandra-5.x-v1-manual 15.01% <ø> (ø)
cassandra-5.x-v2-auto 1.58% <ø> (ø)
cassandra-5.x-v2-manual 1.58% <ø> (ø)
elasticsearch-6.x-v1 18.77% <ø> (-0.01%) ⬇️
elasticsearch-7.x-v1 18.86% <ø> (+<0.01%) ⬆️
elasticsearch-8.x-v1 19.02% <ø> (ø)
elasticsearch-8.x-v2 1.63% <ø> (ø)
grpc_v1 10.68% <ø> (ø)
grpc_v2 7.94% <ø> (-0.01%) ⬇️
kafka-v1 9.37% <ø> (ø)
kafka-v2 1.64% <ø> (ø)
memory_v2 1.63% <ø> (-0.01%) ⬇️
opensearch-1.x-v1 18.89% <ø> (-0.01%) ⬇️
opensearch-2.x-v1 18.90% <ø> (+<0.01%) ⬆️
opensearch-2.x-v2 1.63% <ø> (ø)
tailsampling-processor 0.47% <ø> (ø)
unittests 95.04% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Mahad Zaryab <[email protected]>
s.sortAttributes(resource.Attributes())
scopeSpans := rs.ScopeSpans()
for j := 0; j < scopeSpans.Len(); j++ {
ss := scopeSpans.At(j)
Copy link
Member

Choose a reason for hiding this comment

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

why not sort scope attributes?

Suggested change
ss := scopeSpans.At(j)
ss := scopeSpans.At(j)
s.sortAttributes(ss.Attributes())

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro Done. And did the same for link attributes as well. We should have all collections accounted for now which should provide us with a way to deterministic hash the traces.

@mahadzaryab1 mahadzaryab1 merged commit 6032db9 into jaegertracing:main Dec 20, 2024
54 checks passed
@mahadzaryab1 mahadzaryab1 deleted the sort-adjuster branch December 20, 2024 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants