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

[v2][query] Create archive reader/writer using regular factory methods #6519

Merged
merged 15 commits into from
Jan 17, 2025
Merged
26 changes: 15 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 All @@ -23,7 +24,6 @@ import (
"github.com/jaegertracing/jaeger/plugin/metricstore/disabled"
"github.com/jaegertracing/jaeger/storage/metricstore"
"github.com/jaegertracing/jaeger/storage_v2/depstore"
"github.com/jaegertracing/jaeger/storage_v2/v1adapter"
)

var (
Expand Down Expand Up @@ -94,8 +94,7 @@ 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 {
if err := s.addArchiveStorage(&v2opts, host); err != nil {
return err
}
qs := querysvc.NewQueryService(traceReader, depReader, opts)
Expand Down Expand Up @@ -131,7 +130,6 @@ func (s *server) Start(ctx context.Context, host component.Host) error {
}

func (s *server) addArchiveStorage(
opts *querysvc.QueryServiceOptions,
v2opts *v2querysvc.QueryServiceOptions,
host component.Host,
) error {
Expand All @@ -140,19 +138,25 @@ func (s *server) addArchiveStorage(
return nil
}

f, err := jaegerstorage.GetStorageFactory(s.config.Storage.TracesArchive, host)
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this method anywhere? If yes, can that code be upgraded as well? If no, I would remove 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.

Copy link
Member

Choose a reason for hiding this comment

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

Ok let's book child tickets to address that

f, err := jaegerstorage.GetTraceStoreFactory(s.config.Storage.TracesArchive, host)
if err != nil {
return fmt.Errorf("cannot find 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 archive storage reader", zap.Error(err))
return nil
}
writer, err := f.CreateTraceWriter()
if err != nil {
s.telset.Logger.Error("Cannot init archive storage writer", zap.Error(err))
return nil
}

ar, aw := v1adapter.InitializeArchiveStorage(f, s.telset.Logger)
if ar != nil && aw != nil {
v2opts.ArchiveTraceReader = ar
v2opts.ArchiveTraceWriter = aw
if reader != nil && writer != nil {
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
v2opts.ArchiveTraceReader = reader
v2opts.ArchiveTraceWriter = writer
} else {
s.telset.Logger.Info("Archive storage not initialized")
}
Expand Down
28 changes: 16 additions & 12 deletions cmd/jaeger/internal/extension/jaegerquery/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"go.uber.org/zap/zaptest"

"github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
v2querysvc "github.com/jaegertracing/jaeger/cmd/query/app/querysvc/v2/querysvc"
"github.com/jaegertracing/jaeger/internal/grpctest"
"github.com/jaegertracing/jaeger/pkg/metrics"
Expand Down Expand Up @@ -271,7 +270,6 @@ func TestServerAddArchiveStorage(t *testing.T) {

tests := []struct {
name string
qSvcOpts *querysvc.QueryServiceOptions
v2qSvcOpts *v2querysvc.QueryServiceOptions
config *Config
extension component.Component
Expand All @@ -281,7 +279,6 @@ func TestServerAddArchiveStorage(t *testing.T) {
{
name: "Archive storage unset",
config: &Config{},
qSvcOpts: &querysvc.QueryServiceOptions{},
v2qSvcOpts: &v2querysvc.QueryServiceOptions{},
expectedOutput: `{"level":"info","msg":"Archive storage not configured"}` + "\n",
expectedErr: "",
Expand All @@ -293,32 +290,39 @@ func TestServerAddArchiveStorage(t *testing.T) {
TracesArchive: "random-value",
},
},
qSvcOpts: &querysvc.QueryServiceOptions{},
v2qSvcOpts: &v2querysvc.QueryServiceOptions{},
expectedOutput: "",
expectedErr: "cannot find archive storage factory: cannot find extension",
},
{
name: "Archive storage not supported",
name: "Archive storage span reader error",
config: &Config{
Storage: Storage{
TracesArchive: "no-archive",
TracesArchive: "need-span-reader-error",
},
},
qSvcOpts: &querysvc.QueryServiceOptions{},
v2qSvcOpts: &v2querysvc.QueryServiceOptions{},
extension: fakeStorageExt{},
expectedOutput: "Archive storage not supported by the factory",
expectedErr: "",
expectedOutput: "Cannot init archive storage reader",
},
{
name: "Archive storage span writer error",
config: &Config{
Storage: Storage{
TracesArchive: "need-span-writer-error",
},
},
v2qSvcOpts: &v2querysvc.QueryServiceOptions{},
extension: fakeStorageExt{},
expectedOutput: "Cannot init archive storage writer",
},
{
name: "Archive storage supported",
name: "Archive storage exists",
config: &Config{
Storage: Storage{
TracesArchive: "some-archive-storage",
},
},
qSvcOpts: &querysvc.QueryServiceOptions{},
v2qSvcOpts: &v2querysvc.QueryServiceOptions{},
extension: fakeStorageExt{},
expectedOutput: "",
Expand All @@ -338,7 +342,7 @@ func TestServerAddArchiveStorage(t *testing.T) {
if tt.extension != nil {
host = storagetest.NewStorageHost().WithExtension(jaegerstorage.ID, tt.extension)
}
err := server.addArchiveStorage(tt.qSvcOpts, tt.v2qSvcOpts, host)
err := server.addArchiveStorage(tt.v2qSvcOpts, host)
if tt.expectedErr == "" {
require.NoError(t, err)
} else {
Expand Down
Loading