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

[storage][v2] Implement GetTrace in v2 factory adapter #6329

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

Which problem is this PR solving?

Description of the changes

  • This PR implements GetTrace in the v2 factory adapter

How was this change tested?

  • Added unit tests

Checklist

@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner December 9, 2024 00:16
func (*TraceReader) GetTrace(_ context.Context, _ pcommon.TraceID) (ptrace.Traces, error) {
panic("not implemented")
func (tr *TraceReader) GetTrace(ctx context.Context, traceID pcommon.TraceID) (ptrace.Traces, error) {
tid, _ := model.TraceIDFromBytes(traceID[:])
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 are we okay to ignore this error? or do we want to handle it? An error is only returned if the length of the traceID isn't 8 or 16 and pcommon.TraceID is defined as type TraceID [16]byte

Copy link
Member

Choose a reason for hiding this comment

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

If it's easy to test I wouldn't ignore it.

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 Its not possible to because the length of traceID is always 16 so the error will never be triggered. Let me know if I'm missing something though.

Copy link
Member

Choose a reason for hiding this comment

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

if len=16 is guaranteed, I would just create TraceIDFromOTEL function that doesn't return an error.

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 thanks for the suggestion - done

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.15%. Comparing base (737b9be) to head (550d76e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6329      +/-   ##
==========================================
+ Coverage   96.12%   96.15%   +0.02%     
==========================================
  Files         357      357              
  Lines       20537    20547      +10     
==========================================
+ Hits        19742    19757      +15     
+ Misses        607      603       -4     
+ Partials      188      187       -1     
Flag Coverage Δ
badger_v1 8.77% <0.00%> (-0.01%) ⬇️
badger_v2 1.61% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v1-manual 14.63% <0.00%> (-0.02%) ⬇️
cassandra-4.x-v2-auto 1.55% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v2-manual 1.55% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v1-manual 14.63% <0.00%> (-0.02%) ⬇️
cassandra-5.x-v2-auto 1.55% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v2-manual 1.55% <0.00%> (-0.01%) ⬇️
elasticsearch-6.x-v1 18.34% <0.00%> (-0.02%) ⬇️
elasticsearch-7.x-v1 18.41% <0.00%> (-0.03%) ⬇️
elasticsearch-8.x-v1 18.58% <0.00%> (-0.02%) ⬇️
elasticsearch-8.x-v2 1.60% <0.00%> (-0.02%) ⬇️
grpc_v1 10.21% <0.00%> (-0.02%) ⬇️
grpc_v2 7.80% <0.00%> (-0.01%) ⬇️
kafka-v1 8.46% <0.00%> (-0.01%) ⬇️
kafka-v2 1.61% <0.00%> (-0.01%) ⬇️
memory_v2 1.61% <0.00%> (-0.01%) ⬇️
opensearch-1.x-v1 18.46% <0.00%> (-0.02%) ⬇️
opensearch-2.x-v1 18.46% <0.00%> (-0.03%) ⬇️
opensearch-2.x-v2 1.60% <0.00%> (-0.02%) ⬇️
tailsampling-processor 0.45% <0.00%> (-0.01%) ⬇️
unittests 95.06% <100.00%> (+0.02%) ⬆️

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.

model/ids.go Outdated
@@ -156,6 +156,11 @@ func (t *TraceID) ToOTELTraceID() pcommon.TraceID {
return traceID
}

func TraceIDFromOTEL(traceID pcommon.TraceID) TraceID {
tid, _ := TraceIDFromBytes(traceID[:])
Copy link
Member

Choose a reason for hiding this comment

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

not exactly what I meant. I would move the 16-byte logic from TraceIDFromBytes() into this new function, and invoke this new function from TraceIDFromBytes()

Copy link
Collaborator Author

@mahadzaryab1 mahadzaryab1 Dec 9, 2024

Choose a reason for hiding this comment

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

what about something like this? or do we want this to be more generic to just accept any 16 byte array so that it can be used from TraceIDFromBytes?

func TraceIDFromOTEL(traceID pcommon.TraceID) TraceID {
	return TraceID{
		High: binary.BigEndian.Uint64(traceID[:traceIDShortBytesLen]),
		Low:  binary.BigEndian.Uint64(traceID[traceIDShortBytesLen:]),
	}
}

Signed-off-by: Mahad Zaryab <[email protected]>
@mahadzaryab1 mahadzaryab1 merged commit 5bef8fd into jaegertracing:main Dec 9, 2024
54 checks passed
@mahadzaryab1 mahadzaryab1 deleted the implement-factory-4 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