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][v2][query] Create archive reader/writer using regular factory methods #6519

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
39 changes: 28 additions & 11 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/extension/extensioncapabilities"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage"
queryApp "github.com/jaegertracing/jaeger/cmd/query/app"
Expand Down Expand Up @@ -94,7 +95,6 @@ func (s *server) Start(ctx context.Context, host component.Host) error {

var opts querysvc.QueryServiceOptions
var v2opts v2querysvc.QueryServiceOptions
// TODO archive storage still uses v1 factory
if err := s.addArchiveStorage(&opts, &v2opts, host); err != nil {
return err
}
Expand Down Expand Up @@ -140,23 +140,40 @@ func (s *server) addArchiveStorage(
return nil
}

f, err := jaegerstorage.GetStorageFactory(s.config.Storage.TracesArchive, host)
f, err := jaegerstorage.GetTraceStoreFactory(s.config.Storage.TracesArchive, host)
if err != nil {
return fmt.Errorf("cannot find archive storage factory: %w", err)
return fmt.Errorf("cannot find traces archive storage factory: %w", err)
}

if !opts.InitArchiveStorage(f, s.telset.Logger) {
s.telset.Logger.Info("Archive storage not initialized")
reader, err := f.CreateTraceReader()
if err != nil {
s.telset.Logger.Error("Cannot init traces archive storage reader", zap.Error(err))
return nil
}
writer, err := f.CreateTraceWriter()
if err != nil {
s.telset.Logger.Error("Cannot init traces archive storage writer", zap.Error(err))
return nil
}
v2opts.ArchiveTraceReader = reader
v2opts.ArchiveTraceWriter = writer

ar, aw := v1adapter.InitializeArchiveStorage(f, s.telset.Logger)
if ar != nil && aw != nil {
v2opts.ArchiveTraceReader = ar
v2opts.ArchiveTraceWriter = aw
} else {
s.telset.Logger.Info("Archive storage not initialized")
v1Reader, err := v1adapter.GetV1Reader(reader)
if err != nil {
// if the spanstore.Reader is not available, downgrade the native tracestore.Reader to
// a spanstore.Reader
v1Reader = v1adapter.NewSpanReader(reader)
}

v1Writer, err := v1adapter.GetV1Writer(writer)
if err != nil {
// TODO: implement an adapter to downgrade a tracestore.Writer to a spanstore.Writer
panic("downgrade tracestore.Writer to spanstore.Writer is not implemented")
}

opts.ArchiveSpanReader = v1Reader
opts.ArchiveSpanWriter = v1Writer

return nil
}

Expand Down
Loading