Skip to content

Commit

Permalink
Fix Archive Initialization
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Dec 31, 2024
1 parent 38097ed commit 4b2e6ca
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 21 deletions.
28 changes: 18 additions & 10 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,33 +164,41 @@ func (s *server) addV2ArchiveStorage(opts *v2querysvc.QueryServiceOptions, host
return fmt.Errorf("cannot find archive storage factory: %w", err)
}

archiveFactory, ok := f.(storage.ArchiveFactory)
if !s.initializeV2ArchiveStorage(f, opts) {
s.telset.Logger.Info("Archive storage not initialized")
}
return nil
}

func (s *server) initializeV2ArchiveStorage(
storageFactory storage.Factory,
opts *v2querysvc.QueryServiceOptions) bool {
archiveFactory, ok := storageFactory.(storage.ArchiveFactory)
if !ok {
s.telset.Logger.Info("Archive storage not supported by the factory")
return false
}
reader, err := archiveFactory.CreateArchiveSpanReader()
if errors.Is(err, storage.ErrArchiveStorageNotConfigured) || errors.Is(err, storage.ErrArchiveStorageNotSupported) {
s.telset.Logger.Info("Archive storage not created", zap.String("reason", err.Error()))
return false
}
if err != nil {
s.telset.Logger.Error("Cannot init archive storage reader", zap.Error(err))
return false
}
writer, err := archiveFactory.CreateArchiveSpanWriter()
if errors.Is(err, storage.ErrArchiveStorageNotConfigured) || errors.Is(err, storage.ErrArchiveStorageNotSupported) {
s.telset.Logger.Info("Archive storage not created", zap.String("reason", err.Error()))
return false
}
if err != nil {
s.telset.Logger.Error("Cannot init archive storage writer", zap.Error(err))
return false
}

if writer != nil && reader != nil {
opts.ArchiveTraceReader = v1adapter.NewTraceReader(reader)
opts.ArchiveTraceWriter = v1adapter.NewTraceWriter(writer)
} else {
s.telset.Logger.Info("Archive storage not initialized")
}

return nil
opts.ArchiveTraceReader = v1adapter.NewTraceReader(reader)
opts.ArchiveTraceWriter = v1adapter.NewTraceWriter(writer)
return true
}

func (s *server) createMetricReader(host component.Host) (metricstore.Reader, error) {
Expand Down
31 changes: 20 additions & 11 deletions cmd/query/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,36 +152,45 @@ func (qOpts *QueryOptions) BuildQueryServiceOptions(storageFactory storage.BaseF

func (qOpts *QueryOptions) BuildV2QueryServiceOptions(storageFactory storage.BaseFactory, logger *zap.Logger) *v2querysvc.QueryServiceOptions {
opts := &v2querysvc.QueryServiceOptions{}
if !initializeV2ArchiveStorage(storageFactory, opts, logger) {
logger.Info("Archive storage not initialized")
}

opts.Adjuster = v2adjuster.Sequence(v2adjuster.StandardAdjusters(qOpts.MaxClockSkewAdjust)...)

return opts
}

func initializeV2ArchiveStorage(
storageFactory storage.BaseFactory,
opts *v2querysvc.QueryServiceOptions,
logger *zap.Logger) bool {
archiveFactory, ok := storageFactory.(storage.ArchiveFactory)
if !ok {
logger.Info("Archive storage not supported by the factory")
return false
}
reader, err := archiveFactory.CreateArchiveSpanReader()
if errors.Is(err, storage.ErrArchiveStorageNotConfigured) || errors.Is(err, storage.ErrArchiveStorageNotSupported) {
logger.Info("Archive storage not created", zap.String("reason", err.Error()))
return false
}
if err != nil {
logger.Error("Cannot init archive storage reader", zap.Error(err))
return false
}
writer, err := archiveFactory.CreateArchiveSpanWriter()
if errors.Is(err, storage.ErrArchiveStorageNotConfigured) || errors.Is(err, storage.ErrArchiveStorageNotSupported) {
logger.Info("Archive storage not created", zap.String("reason", err.Error()))
return false
}
if err != nil {
logger.Error("Cannot init archive storage writer", zap.Error(err))
return false
}

if writer != nil && reader != nil {
opts.ArchiveTraceReader = v1adapter.NewTraceReader(reader)
opts.ArchiveTraceWriter = v1adapter.NewTraceWriter(writer)
} else {
logger.Info("Archive storage not initialized")
}

opts.Adjuster = v2adjuster.Sequence(v2adjuster.StandardAdjusters(qOpts.MaxClockSkewAdjust)...)

return opts
opts.ArchiveTraceReader = v1adapter.NewTraceReader(reader)
opts.ArchiveTraceWriter = v1adapter.NewTraceWriter(writer)
return true
}

// stringSliceAsHeader parses a slice of strings and returns a http.Header.
Expand Down

0 comments on commit 4b2e6ca

Please sign in to comment.