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
Show file tree
Hide file tree
Changes from 4 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
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)
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 {
Copy link
Member

Choose a reason for hiding this comment

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

isn't this always true now? regular Create methods are not allowed to return nil without error

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