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

[WIP] Upgrade storage integration test: Use V2 Archive ReaderWriter #6489

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions plugin/storage/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ func (s *CassandraStorageIntegration) initializeCassandra(t *testing.T) {
spanReader, err := f.CreateSpanReader()
require.NoError(t, err)
s.TraceReader = v1adapter.NewTraceReader(spanReader)
s.ArchiveSpanReader, err = f.CreateArchiveSpanReader()
archiveSpanReader, err := f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
s.ArchiveTraceReader = v1adapter.NewTraceReader(archiveSpanReader)
archiveSpanWriter, err := f.CreateArchiveSpanWriter()
require.NoError(t, err)
s.ArchiveTraceWriter = v1adapter.NewTraceWriter(archiveSpanWriter)
s.SamplingStore, err = f.CreateSamplingStore(0)
require.NoError(t, err)
s.initializeDependencyReaderAndWriter(t, f)
Expand Down
6 changes: 4 additions & 2 deletions plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ func (s *ESStorageIntegration) initSpanstore(t *testing.T, allTagsAsFields bool)
spanReader, err := f.CreateSpanReader()
require.NoError(t, err)
s.TraceReader = v1adapter.NewTraceReader(spanReader)
s.ArchiveSpanReader, err = f.CreateArchiveSpanReader()
archiveSpanReader, err := f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
s.ArchiveTraceReader = v1adapter.NewTraceReader(archiveSpanReader)
archiveSpanWriter, err := f.CreateArchiveSpanWriter()
require.NoError(t, err)
s.ArchiveTraceWriter = v1adapter.NewTraceWriter(archiveSpanWriter)

dependencyReader, err := f.CreateDependencyReader()
require.NoError(t, err)
Expand Down
7 changes: 4 additions & 3 deletions plugin/storage/integration/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ func (s *GRPCStorageIntegrationTestSuite) initialize(t *testing.T) {
spanReader, err := f.CreateSpanReader()
require.NoError(t, err)
s.TraceReader = v1adapter.NewTraceReader(spanReader)
s.ArchiveSpanReader, err = f.CreateArchiveSpanReader()
archiveSpanReader, err := f.CreateArchiveSpanReader()
require.NoError(t, err)
s.ArchiveSpanWriter, err = f.CreateArchiveSpanWriter()
s.ArchiveTraceReader = v1adapter.NewTraceReader(archiveSpanReader)
archiveSpanWriter, err := f.CreateArchiveSpanWriter()
require.NoError(t, err)

s.ArchiveTraceWriter = v1adapter.NewTraceWriter(archiveSpanWriter)
// TODO DependencyWriter is not implemented in grpc store

s.CleanUp = s.cleanUp
Expand Down
48 changes: 28 additions & 20 deletions plugin/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/storage/samplingstore"
samplemodel "github.com/jaegertracing/jaeger/storage/samplingstore/model"
"github.com/jaegertracing/jaeger/storage/spanstore"
"github.com/jaegertracing/jaeger/storage_v2/depstore"
"github.com/jaegertracing/jaeger/storage_v2/tracestore"
"github.com/jaegertracing/jaeger/storage_v2/v1adapter"
Expand All @@ -43,14 +42,14 @@ var fixtures embed.FS
// Some implementations may declare multiple tests, with different settings,
// and RunAll() under different conditions.
type StorageIntegration struct {
TraceWriter tracestore.Writer
TraceReader tracestore.Reader
ArchiveSpanReader spanstore.Reader
ArchiveSpanWriter spanstore.Writer
DependencyWriter depstore.Writer
DependencyReader depstore.Reader
SamplingStore samplingstore.Store
Fixtures []*QueryFixtures
TraceWriter tracestore.Writer
TraceReader tracestore.Reader
ArchiveTraceReader tracestore.Reader
ArchiveTraceWriter tracestore.Writer
DependencyWriter depstore.Writer
DependencyReader depstore.Reader
SamplingStore samplingstore.Store
Fixtures []*QueryFixtures

// TODO: remove this after all storage backends return spanKind from GetOperations
GetOperationsMissingSpanKind bool
Expand Down Expand Up @@ -189,25 +188,34 @@ func (s *StorageIntegration) testArchiveTrace(t *testing.T) {
}
defer s.cleanUp(t)
tID := model.NewTraceID(uint64(11), uint64(22))
expected := &model.Span{
OperationName: "archive_span",
StartTime: time.Now().Add(-time.Hour * 72 * 5).Truncate(time.Microsecond),
TraceID: tID,
SpanID: model.NewSpanID(55),
References: []model.SpanRef{},
Process: model.NewProcess("archived_service", model.KeyValues{}),
expected := &model.Trace{
Spans: []*model.Span{
{
OperationName: "archive_span",
StartTime: time.Now().Add(-time.Hour * 72 * 5).Truncate(time.Microsecond),
TraceID: tID,
SpanID: model.NewSpanID(55),
References: []model.SpanRef{},
Process: model.NewProcess("archived_service", model.KeyValues{}),
},
},
}

require.NoError(t, s.ArchiveSpanWriter.WriteSpan(context.Background(), expected))
require.NoError(t, s.ArchiveTraceWriter.WriteTraces(context.Background(), v1adapter.V1TraceToOtelTrace(expected)))

var actual *model.Trace
found := s.waitForCondition(t, func(_ *testing.T) bool {
var err error
actual, err = s.ArchiveSpanReader.GetTrace(context.Background(), spanstore.GetTraceParameters{TraceID: tID})
return err == nil && len(actual.Spans) == 1
// iterTraces := s.ArchiveTraceReader.GetTraces(context.Background(), tracestore.GetTraceParams{TraceID: tID.ToOTELTraceID()})
// traces, err := v1adapter.V1TracesFromSeq2(iterTraces)
// if len(traces) > 0 {
// actual = traces[0]
// }
actual, err = s.ArchiveTraceReader.(*v1adapter.TraceReader).GetArchiveTraces(context.Background(), tracestore.GetTraceParams{TraceID: tID.ToOTELTraceID()})
ekefan marked this conversation as resolved.
Show resolved Hide resolved
return err == nil && len(actual.Spans) >= len(expected.Spans)
})
require.True(t, found)
CompareTraces(t, &model.Trace{Spans: []*model.Span{expected}}, actual)
CompareTraces(t, expected, actual)
}

func (s *StorageIntegration) testGetLargeSpan(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions plugin/storage/integration/memstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func (s *MemStorageIntegrationTestSuite) initialize(_ *testing.T) {
s.SamplingStore = memory.NewSamplingStore(2)
s.TraceReader = v1adapter.NewTraceReader(store)
s.TraceWriter = v1adapter.NewTraceWriter(store)
s.ArchiveSpanReader = archiveStore
s.ArchiveSpanWriter = archiveStore
s.ArchiveTraceReader = v1adapter.NewTraceReader(archiveStore)
s.ArchiveTraceWriter = v1adapter.NewTraceWriter(archiveStore)

// TODO DependencyWriter is not implemented in memory store

Expand Down
5 changes: 5 additions & 0 deletions storage_v2/v1adapter/tracereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (tr *TraceReader) GetTraces(
}
}

func (tr *TraceReader) GetArchiveTraces(ctx context.Context, traceID tracestore.GetTraceParams) (*model.Trace, error) {
Copy link
Contributor Author

@ekefan ekefan Jan 17, 2025

Choose a reason for hiding this comment

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

Hello @yurishkuro,

For some reason, getting archive traces on es v1 fails when looping through traceIDs

I spent some time, reading codes in the es dir, and recent changes to config for archive traces but I couldn't find anything that pointed the reason for not reading traces. Then I tried this GetArchiveTraces function:

func (tr *TraceReader) GetArchiveTraces(ctx context.Context, traceIDs ...tracestore.GetTraceParams) ([]*model.Trace, error) {
	traces := []*model.Trace{}
	var err error
	for _, traceID := range traceIDs {
		tID := model.TraceIDFromOTEL(traceID.TraceID)
		trace, err := tr.spanReader.GetTrace(ctx, spanstore.GetTraceParameters{TraceID: tID})
		if err != nil {
			if errors.Is(err, spanstore.ErrTraceNotFound) {
				fmt.Printf("Trace with id: %v, not found", tID)
				continue
			} else {
				return nil, err
			}
		}
		traces = append(traces, trace)
	}
	return traces, err
}

and it failed to read too..

But this variant didn't fail..

func (tr *TraceReader) GetArchiveTraces(ctx context.Context, traceIDs ...tracestore.GetTraceParams) ([]*model.Trace, error) {
	traces := []*model.Trace{}
	traceID := traceIDs[0] // trying this out, since only one archive trace is to be read
	tID := model.TraceIDFromOTEL(traceID.TraceID)
	trace, err := tr.spanReader.GetTrace(ctx, spanstore.GetTraceParameters{TraceID: tID})
	if err != nil {
		if errors.Is(err, spanstore.ErrTraceNotFound) {
			fmt.Printf("Trace with id: %v, not found", tID)
		}
		return nil, err
	}
	traces = append(traces, trace)
	return traces, err
}

Since, all jaeger backend storage will be upgraded to version 2, we could use this function till then.
What do you think? about the bug, the suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

there is no such thing as GetArchiveTraces, we never had it even in v1 storage interface, and we explicitly are moving away from in it v2.

Copy link
Contributor Author

@ekefan ekefan Jan 18, 2025

Choose a reason for hiding this comment

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

I totally get that...

I only created it for the purpose of solving the bug we are experiencing hoping it would be no longer be needed soon.

tID := model.TraceIDFromOTEL(traceID.TraceID)
return tr.spanReader.GetTrace(ctx, spanstore.GetTraceParameters{TraceID: tID})
}

func (tr *TraceReader) GetServices(ctx context.Context) ([]string, error) {
return tr.spanReader.GetServices(ctx)
}
Expand Down
Loading