Skip to content

[v2][adjuster] Implement span ID uniquifier adjuster to operate on otlp data model #6367

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

Merged
merged 20 commits into from
Dec 18, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Dec 16, 2024

Which problem is this PR solving?

Description of the changes

  • Implement the Span ID Uniquifier adjuster to operate on the OTLP data model.

How was this change tested?

  • Unit tests

Checklist

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.20%. Comparing base (dd799a0) to head (9b395d5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6367      +/-   ##
==========================================
+ Coverage   96.16%   96.20%   +0.04%     
==========================================
  Files         360      361       +1     
  Lines       20513    20600      +87     
==========================================
+ Hits        19727    19819      +92     
+ Misses        601      597       -4     
+ Partials      185      184       -1     
Flag Coverage Δ
badger_v1 8.96% <ø> (ø)
badger_v2 1.63% <ø> (ø)
cassandra-4.x-v1-manual 14.93% <ø> (ø)
cassandra-4.x-v2-auto 1.57% <ø> (ø)
cassandra-4.x-v2-manual 1.57% <ø> (ø)
cassandra-5.x-v1-manual 14.93% <ø> (ø)
cassandra-5.x-v2-auto 1.57% <ø> (ø)
cassandra-5.x-v2-manual 1.57% <ø> (ø)
elasticsearch-6.x-v1 18.62% <ø> (+<0.01%) ⬆️
elasticsearch-7.x-v1 18.69% <ø> (-0.01%) ⬇️
elasticsearch-8.x-v1 18.85% <ø> (ø)
elasticsearch-8.x-v2 1.62% <ø> (-0.01%) ⬇️
grpc_v1 10.61% <ø> (+<0.01%) ⬆️
grpc_v2 7.95% <ø> (ø)
kafka-v1 9.29% <ø> (ø)
kafka-v2 1.63% <ø> (ø)
memory_v2 1.63% <ø> (+<0.01%) ⬆️
opensearch-1.x-v1 18.75% <ø> (+<0.01%) ⬆️
opensearch-2.x-v1 18.74% <ø> (-0.01%) ⬇️
opensearch-2.x-v2 1.62% <ø> (-0.01%) ⬇️
tailsampling-processor 0.45% <ø> (ø)
unittests 95.09% <100.00%> (+0.04%) ⬆️

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.

Comment on lines 61 to 67
serverSpan := spans.At(1)
assert.EqualValues(t, []byte{0, 0, 0, 0, 0, 0, 0, 2}, serverSpan.SpanID(), "server span ID should be reassigned")
assert.EqualValues(t, []byte{0, 0, 0, 0, 0, 0, 0, 3}, serverSpan.ParentSpanID(), "next server span should be this server span's parent")

anotherServerSpan := spans.At(2)
assert.EqualValues(t, []byte{0, 0, 0, 0, 0, 0, 0, 3}, anotherServerSpan.SpanID(), "server span ID should be reassigned")
assert.EqualValues(t, clientSpanID, anotherServerSpan.ParentSpanID(), "client span should be server span's parent")
Copy link
Collaborator Author

@mahadzaryab1 mahadzaryab1 Dec 16, 2024

Choose a reason for hiding this comment

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

@yurishkuro does this expectation make sense to you? it takes the last repeated span and sets that to be the parent and then adjusts the repeated ones before to have that be the parent. So in this case, the hierarchy becomes clientSpan -> anotherServerSpan -> serverSpan.

Copy link
Member

Choose a reason for hiding this comment

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

first, when you have one client and two server spans sharing the same ID, it's doesn't really make sense and the behavior of adjuster is not well defined, because the condition already violates "shared span id" notion from Zipkin. I think it's technically possible to have if a retry from client was done without creating a new client span. I think a reasonable thing to do in such case is to assign unique IDs to both server spans, such that we get a tree (but not a chain that you have):

clientSpan -> serverSpan
clientSpan -> anotherServerSpan
``
In addition, if there is a 4th span whose `parentId == clientSpanId`, then that 4th span's parent ID must be overwritten to the newly generated span ID. Here we have an ambiguity - it could be either `serverSpan.spanId` or `anotherServerSpan.spanId`, there's no way for us to know (and we should arbitrarily pick first or last reassigned `server` span).

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 Ah okay. I'm happy to remove this test if the behaviour is undefined then because it didn't exist in the old implementation either.

@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review December 17, 2024 00:00
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner December 17, 2024 00:00
@dosubot dosubot bot added the v2 label Dec 17, 2024
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>

serverSpan := spans.At(1)
assert.EqualValues(t, []byte{0, 0, 0, 0, 0, 0, 0, 2}, serverSpan.SpanID(), "server span ID should be reassigned")
assert.EqualValues(t, []byte{0, 0, 0, 0, 0, 0, 0, 3}, serverSpan.ParentSpanID(), "next server span should be this server span's parent")
Copy link
Member

Choose a reason for hiding this comment

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

I would expect serverSpan.parentSpanId == clientSpanID. If it's id=3, there was no such span in the trace before, so it's a broken link.

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 That's what i was expecting as well but this is a direct translation of what was there before. If you take a look at the old implementation, oldToNewSpanIDs gets overwritten with the latest trace that it encounters which is what causes this. Do we want to change the behaviour here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was due to the undefined behaviour resulting from a having two server spans sharing the same clientID. This is now fixed.

Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
serverSpan := spans.AppendEmpty()
serverSpan.SetTraceID(traceID)
serverSpan.SetSpanID(clientSpanID) // shared span ID
serverSpan.SetKind(ptrace.SpanKindServer)
Copy link
Member

Choose a reason for hiding this comment

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

so you dropped the edge case of two server spans sharing client span id? Maybe it's for the better - we always wanted to support partial spans where we could have 2+ span "chunks" sharing the ID which should be merged into a single span. To support partial spans and this use case of dual server spans sharing client span ID we'd need to be very careful about examining the Resource/Scope of the spans to ensure they are identical (or one is empty).

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 Yeah I dropped it given that the behaviour is undefined and in favour of keeping the implementation the same as the existing adjuster. Happy to revisit this again in the future if we want to support partial spans as you suggested.

@mahadzaryab1 mahadzaryab1 enabled auto-merge (squash) December 18, 2024 03:21
@mahadzaryab1 mahadzaryab1 merged commit 376061e into jaegertracing:main Dec 18, 2024
54 checks passed
@mahadzaryab1 mahadzaryab1 deleted the zipkin-span-id-uniqify branch January 6, 2025 00:42
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