-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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][storage] Implement reverse adapter to translate v2 storage api to v1 #6485
Merged
mahadzaryab1
merged 14 commits into
jaegertracing:main
from
mahadzaryab1:reverse-adapter
Jan 5, 2025
+623
−14
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
20b9275
Implement Reverse Adapter For Storage API
mahadzaryab1 bba26c4
Merge branch 'main' into reverse-adapter
mahadzaryab1 84c7900
Add Interface Check
mahadzaryab1 2c2d339
Create Helper Function In Translator
mahadzaryab1 88efc5e
Add Unit Tests For Helper
mahadzaryab1 ded8965
Add Unit Tests For GetTrace
mahadzaryab1 7f3c244
Run Formatter And Add Remaining Unit Tests
mahadzaryab1 5cbb918
Use Reverse Adapter In Query Service
mahadzaryab1 c639363
Add godoc Comment
mahadzaryab1 9395e67
Remove Unused Statement
mahadzaryab1 153ff63
Drive By: Fix Function Name
mahadzaryab1 fa5db45
Add Condition For Too Many Traces
mahadzaryab1 947b173
Add Test For FindTraceIDs
mahadzaryab1 c61aa0e
Merge branch 'main' into reverse-adapter
mahadzaryab1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package v1adapter | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"github.com/jaegertracing/jaeger/model" | ||
"github.com/jaegertracing/jaeger/storage/spanstore" | ||
"github.com/jaegertracing/jaeger/storage_v2/tracestore" | ||
) | ||
|
||
var _ spanstore.Reader = (*SpanReader)(nil) | ||
|
||
var errTooManyTracesFound = errors.New("too many traces found") | ||
|
||
// SpanReader wraps a tracestore.Reader so that it can be downgraded to implement | ||
// the v1 spanstore.Reader interface. | ||
type SpanReader struct { | ||
traceReader tracestore.Reader | ||
} | ||
|
||
func NewSpanReader(traceReader tracestore.Reader) *SpanReader { | ||
return &SpanReader{ | ||
traceReader: traceReader, | ||
} | ||
} | ||
|
||
func (sr *SpanReader) GetTrace(ctx context.Context, query spanstore.GetTraceParameters) (*model.Trace, error) { | ||
getTracesIter := sr.traceReader.GetTraces(ctx, tracestore.GetTraceParams{ | ||
TraceID: query.TraceID.ToOTELTraceID(), | ||
Start: query.StartTime, | ||
End: query.EndTime, | ||
}) | ||
traces, err := V1TracesFromSeq2(getTracesIter) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(traces) == 0 { | ||
return nil, spanstore.ErrTraceNotFound | ||
} else if len(traces) > 1 { | ||
return nil, errTooManyTracesFound | ||
} | ||
return traces[0], nil | ||
yurishkuro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func (sr *SpanReader) GetServices(ctx context.Context) ([]string, error) { | ||
return sr.traceReader.GetServices(ctx) | ||
} | ||
|
||
func (sr *SpanReader) GetOperations( | ||
ctx context.Context, | ||
query spanstore.OperationQueryParameters, | ||
) ([]spanstore.Operation, error) { | ||
o, err := sr.traceReader.GetOperations(ctx, tracestore.OperationQueryParams{ | ||
ServiceName: query.ServiceName, | ||
SpanKind: query.SpanKind, | ||
}) | ||
if err != nil || o == nil { | ||
return nil, err | ||
} | ||
operations := []spanstore.Operation{} | ||
for _, operation := range o { | ||
operations = append(operations, spanstore.Operation{ | ||
Name: operation.Name, | ||
SpanKind: operation.SpanKind, | ||
}) | ||
} | ||
return operations, nil | ||
} | ||
|
||
func (sr *SpanReader) FindTraces( | ||
ctx context.Context, | ||
query *spanstore.TraceQueryParameters, | ||
) ([]*model.Trace, error) { | ||
getTracesIter := sr.traceReader.FindTraces(ctx, tracestore.TraceQueryParams{ | ||
ServiceName: query.ServiceName, | ||
OperationName: query.OperationName, | ||
Tags: query.Tags, | ||
StartTimeMin: query.StartTimeMin, | ||
StartTimeMax: query.StartTimeMax, | ||
DurationMin: query.DurationMin, | ||
DurationMax: query.DurationMax, | ||
NumTraces: query.NumTraces, | ||
}) | ||
return V1TracesFromSeq2(getTracesIter) | ||
} | ||
|
||
func (sr *SpanReader) FindTraceIDs( | ||
ctx context.Context, | ||
query *spanstore.TraceQueryParameters, | ||
) ([]model.TraceID, error) { | ||
traceIDsIter := sr.traceReader.FindTraceIDs(ctx, tracestore.TraceQueryParams{ | ||
ServiceName: query.ServiceName, | ||
OperationName: query.OperationName, | ||
Tags: query.Tags, | ||
StartTimeMin: query.StartTimeMin, | ||
StartTimeMax: query.StartTimeMax, | ||
DurationMin: query.DurationMin, | ||
DurationMax: query.DurationMax, | ||
NumTraces: query.NumTraces, | ||
}) | ||
return V1TraceIDsFromSeq2(traceIDsIter) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
drive by change: i forgot to change the name of this function in a previous PR