-
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
[storage][v2] Add reader adapter that just exposes the underlying v1 reader #6221
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2024 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package factoryadapter | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"go.opentelemetry.io/collector/pdata/pcommon" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
|
||
spanstore_v1 "github.com/jaegertracing/jaeger/storage/spanstore" | ||
"github.com/jaegertracing/jaeger/storage_v2/spanstore" | ||
) | ||
|
||
var errV1ReaderNotAvailable = errors.New("spanstore.Reader is not a wrapper around v1 reader") | ||
|
||
type TraceReader struct { | ||
spanReader spanstore_v1.Reader | ||
} | ||
|
||
func GetV1Reader(reader spanstore.Reader) (spanstore_v1.Reader, error) { | ||
if tr, ok := reader.(*TraceReader); ok { | ||
return tr.spanReader, nil | ||
} | ||
return nil, errV1ReaderNotAvailable | ||
} | ||
|
||
func NewTraceReader(spanReader spanstore_v1.Reader) *TraceReader { | ||
return &TraceReader{ | ||
spanReader: spanReader, | ||
} | ||
} | ||
|
||
func (*TraceReader) GetTrace(_ context.Context, _ pcommon.TraceID) (ptrace.Traces, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func (*TraceReader) GetServices(_ context.Context) ([]string, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func (*TraceReader) GetOperations(_ context.Context, _ spanstore.OperationQueryParameters) ([]spanstore.Operation, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func (*TraceReader) FindTraces(_ context.Context, _ spanstore.TraceQueryParameters) ([]ptrace.Traces, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func (*TraceReader) FindTraceIDs(_ context.Context, _ spanstore.TraceQueryParameters) ([]pcommon.TraceID, error) { | ||
panic("not implemented") | ||
} |
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,103 @@ | ||
// Copyright (c) 2024 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package factoryadapter | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/pdata/pcommon" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
|
||
"github.com/jaegertracing/jaeger/plugin/storage/memory" | ||
"github.com/jaegertracing/jaeger/storage_v2/spanstore" | ||
) | ||
|
||
func TestGetV1Reader_NoError(t *testing.T) { | ||
memstore := memory.NewStore() | ||
traceReader := &TraceReader{ | ||
spanReader: memstore, | ||
} | ||
v1Reader, err := GetV1Reader(traceReader) | ||
require.NoError(t, err) | ||
require.Equal(t, memstore, v1Reader) | ||
} | ||
|
||
type fakeReader struct{} | ||
|
||
func (*fakeReader) GetTrace(_ context.Context, _ pcommon.TraceID) (ptrace.Traces, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func (*fakeReader) GetServices(_ context.Context) ([]string, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func (*fakeReader) GetOperations(_ context.Context, _ spanstore.OperationQueryParameters) ([]spanstore.Operation, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func (*fakeReader) FindTraces(_ context.Context, _ spanstore.TraceQueryParameters) ([]ptrace.Traces, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func (*fakeReader) FindTraceIDs(_ context.Context, _ spanstore.TraceQueryParameters) ([]pcommon.TraceID, error) { | ||
panic("not implemented") | ||
} | ||
|
||
func TestGetV1Reader_Error(t *testing.T) { | ||
fr := &fakeReader{} | ||
_, err := GetV1Reader(fr) | ||
require.ErrorIs(t, err, errV1ReaderNotAvailable) | ||
} | ||
|
||
func TestTraceReader_GetTracePanics(t *testing.T) { | ||
memstore := memory.NewStore() | ||
traceReader := &TraceReader{ | ||
spanReader: memstore, | ||
} | ||
require.Panics(t, func() { traceReader.GetTrace(context.Background(), pcommon.NewTraceIDEmpty()) }) | ||
} | ||
|
||
func TestTraceReader_GetServicesPanics(t *testing.T) { | ||
memstore := memory.NewStore() | ||
traceReader := &TraceReader{ | ||
spanReader: memstore, | ||
} | ||
require.Panics(t, func() { traceReader.GetServices(context.Background()) }) | ||
} | ||
|
||
func TestTraceReader_GetOperationsPanics(t *testing.T) { | ||
memstore := memory.NewStore() | ||
traceReader := &TraceReader{ | ||
spanReader: memstore, | ||
} | ||
require.Panics( | ||
t, | ||
func() { traceReader.GetOperations(context.Background(), spanstore.OperationQueryParameters{}) }, | ||
) | ||
} | ||
|
||
func TestTraceReader_FindTracesPanics(t *testing.T) { | ||
memstore := memory.NewStore() | ||
traceReader := &TraceReader{ | ||
spanReader: memstore, | ||
} | ||
require.Panics( | ||
t, | ||
func() { traceReader.FindTraces(context.Background(), spanstore.TraceQueryParameters{}) }, | ||
) | ||
} | ||
|
||
func TestTraceReader_FindTraceIDsPanics(t *testing.T) { | ||
memstore := memory.NewStore() | ||
traceReader := &TraceReader{ | ||
spanReader: memstore, | ||
} | ||
require.Panics( | ||
t, | ||
func() { traceReader.FindTraceIDs(context.Background(), spanstore.TraceQueryParameters{}) }, | ||
) | ||
} |
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.
at some point we would need to implement these methods, because as soon as we start upgrading query subcomponents to use v2 storage api directly (e.g. the apiv3 handler, the easiest to upgrade since it already returns OTLP formats) they will be blocked on this implementation for v1-only backends.
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.
@yurishkuro what would these implementations look like?
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.
you would call the underlying v1 reader to retrieve the trace and then convert the result into OTLP data model