Skip to content

Commit

Permalink
Initialize V2 Factories And Use CreateTraceReader
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Nov 17, 2024
1 parent 6ee0470 commit c34845c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
13 changes: 6 additions & 7 deletions cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ import (
"github.com/jaegertracing/jaeger/ports"
"github.com/jaegertracing/jaeger/storage/dependencystore"
metricsstoreMetrics "github.com/jaegertracing/jaeger/storage/metricsstore/metrics"
"github.com/jaegertracing/jaeger/storage/spanstore"
storageMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
"github.com/jaegertracing/jaeger/storage_v2/spanstore"
)

// all-in-one/main is a standalone full-stack jaeger backend, backed by a memory store
Expand All @@ -57,6 +56,7 @@ func main() {
if err != nil {
log.Fatalf("Cannot initialize storage factory: %v", err)
}
v2Factory := factoryadapter.NewFactory(storageFactory)
samplingStrategyFactoryConfig, err := ss.FactoryConfigFromEnv()
if err != nil {
log.Fatalf("Cannot initialize sampling strategy factory config: %v", err)
Expand Down Expand Up @@ -98,7 +98,7 @@ by default uses only in-memory database.`,
logger.Fatal("Failed to init storage factory", zap.Error(err))
}

spanReader, err := storageFactory.CreateSpanReader()
traceReader, err := v2Factory.CreateTraceReader()
if err != nil {
logger.Fatal("Failed to create span reader", zap.Error(err))
}
Expand Down Expand Up @@ -166,7 +166,7 @@ by default uses only in-memory database.`,
// query
querySrv := startQuery(
svc, qOpts, qOpts.BuildQueryServiceOptions(storageFactory, logger),
spanReader, dependencyReader, metricsQueryService,
traceReader, dependencyReader, metricsQueryService,
tm, telset,
)

Expand Down Expand Up @@ -213,14 +213,13 @@ func startQuery(
svc *flags.Service,
qOpts *queryApp.QueryOptions,
queryOpts *querysvc.QueryServiceOptions,
spanReader spanstore.Reader,
traceReader spanstore.Reader,
depReader dependencystore.Reader,
metricsQueryService querysvc.MetricsQueryService,
tm *tenancy.Manager,
telset telemetery.Setting,
) *queryApp.Server {
spanReader = storageMetrics.NewReadMetricsDecorator(spanReader, telset.Metrics)
traceReader := factoryadapter.NewTraceReader(spanReader)
// TODO: decorate trace reader with metrics
qs := querysvc.NewQueryService(traceReader, depReader, *queryOpts)

server, err := queryApp.NewServer(context.Background(), qs, metricsQueryService, qOpts, tm, telset)
Expand Down
18 changes: 10 additions & 8 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/plugin/metrics/disabled"
"github.com/jaegertracing/jaeger/storage/metricsstore"
storageMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

var (
Expand Down Expand Up @@ -56,20 +54,24 @@ func (s *server) Start(ctx context.Context, host component.Host) error {
mf := otelmetrics.NewFactory(s.telset.MeterProvider)
baseFactory := mf.Namespace(metrics.NSOptions{Name: "jaeger"})
queryMetricsFactory := baseFactory.Namespace(metrics.NSOptions{Name: "query"})
f, err := jaegerstorage.GetStorageFactory(s.config.Storage.TracesPrimary, host)
v1Factory, err := jaegerstorage.GetStorageFactory(s.config.Storage.TracesPrimary, host)
if err != nil {
return fmt.Errorf("cannot find primary storage %s: %w", s.config.Storage.TracesPrimary, err)
return fmt.Errorf("cannot find primary storage from v1 factory %s: %w", s.config.Storage.TracesPrimary, err)
}
v2Factory, err := jaegerstorage.GetStorageFactoryV2(s.config.Storage.TracesPrimary, host)
if err != nil {
return fmt.Errorf("cannot find primary storage from v2 factory %s: %w", s.config.Storage.TracesPrimary, err)
}

spanReader, err := f.CreateSpanReader()
v1Factory.CreateSpanReader()
traceReader, err := v2Factory.CreateTraceReader()
if err != nil {
return fmt.Errorf("cannot create span reader: %w", err)
}

spanReader = storageMetrics.NewReadMetricsDecorator(spanReader, queryMetricsFactory)
traceReader := factoryadapter.NewTraceReader(spanReader)
// TODO: decorate trace reader with metrics

depReader, err := f.CreateDependencyReader()
depReader, err := v1Factory.CreateDependencyReader()
if err != nil {
return fmt.Errorf("cannot create dependencies reader: %w", err)
}
Expand Down
9 changes: 4 additions & 5 deletions cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/jaegertracing/jaeger/plugin/storage"
"github.com/jaegertracing/jaeger/ports"
metricsstoreMetrics "github.com/jaegertracing/jaeger/storage/metricsstore/metrics"
spanstoreMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
)

Expand All @@ -44,6 +43,7 @@ func main() {
if err != nil {
log.Fatalf("Cannot initialize storage factory: %v", err)
}
v2Factory := factoryadapter.NewFactory(storageFactory)

fc := metricsPlugin.FactoryConfigFromEnv()
metricsReaderFactory, err := metricsPlugin.NewFactory(fc)
Expand Down Expand Up @@ -85,12 +85,11 @@ func main() {
if err := storageFactory.Initialize(baseFactory, logger); err != nil {
logger.Fatal("Failed to init storage factory", zap.Error(err))
}
spanReader, err := storageFactory.CreateSpanReader()
traceReader, err := v2Factory.CreateTraceReader()
if err != nil {
logger.Fatal("Failed to create span reader", zap.Error(err))
logger.Fatal("Failed to create trace reader", zap.Error(err))
}
spanReader = spanstoreMetrics.NewReadMetricsDecorator(spanReader, metricsFactory)
traceReader := factoryadapter.NewTraceReader(spanReader)
// TODO: decorate trace reader with metrics
dependencyReader, err := storageFactory.CreateDependencyReader()
if err != nil {
logger.Fatal("Failed to create dependency reader", zap.Error(err))
Expand Down

0 comments on commit c34845c

Please sign in to comment.