Skip to content

Commit

Permalink
Create Separate Accessors For Trace And Dependency Stores
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Dec 7, 2024
1 parent 55d3d19 commit f43ec56
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/exporters/storageexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func newExporter(config *Config, otel component.TelemetrySettings) *storageExpor
}

func (exp *storageExporter) start(_ context.Context, host component.Host) error {
f, err := jaegerstorage.GetStorageFactoryV2(exp.config.TraceStorage, host)
f, err := jaegerstorage.GetTraceStoreFactory(exp.config.TraceStorage, host)
if err != nil {
return fmt.Errorf("cannot find storage factory: %w", err)
}
Expand Down
13 changes: 8 additions & 5 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,20 @@ func (s *server) Start(ctx context.Context, host component.Host) error {
telset.Metrics = telset.Metrics.
Namespace(metrics.NSOptions{Name: "jaeger"}).
Namespace(metrics.NSOptions{Name: "query"})
f, err := jaegerstorage.GetStorageFactoryV2(s.config.Storage.TracesPrimary, host)
tf, err := jaegerstorage.GetTraceStoreFactory(s.config.Storage.TracesPrimary, host)
if err != nil {
return fmt.Errorf("cannot find factory for primary storage %s: %w", s.config.Storage.TracesPrimary, err)
return fmt.Errorf("cannot find factory for trace storage %s: %w", s.config.Storage.TracesPrimary, err)
}

traceReader, err := f.CreateTraceReader()
traceReader, err := tf.CreateTraceReader()
if err != nil {
return fmt.Errorf("cannot create trace reader: %w", err)
}

depReader, err := f.CreateDependencyReader()
df, err := jaegerstorage.GetDependencyStoreFactory(s.config.Storage.TracesPrimary, host)
if err != nil {
return fmt.Errorf("cannot find factory for dependency storage %s: %w", s.config.Storage.TracesPrimary, err)

Check warning on line 85 in cmd/jaeger/internal/extension/jaegerquery/server.go

View check run for this annotation

Codecov / codecov/patch

cmd/jaeger/internal/extension/jaegerquery/server.go#L85

Added line #L85 was not covered by tests
}
depReader, err := df.CreateDependencyReader()
if err != nil {
return fmt.Errorf("cannot create dependencies reader: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/extension/jaegerquery/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestServerStart(t *testing.T) {
TracesPrimary: "need-factory-error",
},
},
expectedErr: "cannot find factory for primary storage",
expectedErr: "cannot find factory for trace storage",
},
{
name: "span reader error",
Expand Down
12 changes: 11 additions & 1 deletion cmd/jaeger/internal/extension/jaegerstorage/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"github.com/jaegertracing/jaeger/plugin/storage/grpc"
"github.com/jaegertracing/jaeger/plugin/storage/memory"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage_v2/depstore"
"github.com/jaegertracing/jaeger/storage_v2/factoryadapter"
"github.com/jaegertracing/jaeger/storage_v2/tracestore"
)

var _ Extension = (*storageExt)(nil)
Expand Down Expand Up @@ -73,7 +75,15 @@ func GetMetricStorageFactory(name string, host component.Host) (storage.MetricSt
return mf, nil
}

func GetStorageFactoryV2(name string, host component.Host) (*factoryadapter.Factory, error) {
func GetTraceStoreFactory(name string, host component.Host) (tracestore.Factory, error) {
return getV2FactoryAdapter(name, host)
}

func GetDependencyStoreFactory(name string, host component.Host) (depstore.Factory, error) {
return getV2FactoryAdapter(name, host)

Check warning on line 83 in cmd/jaeger/internal/extension/jaegerstorage/extension.go

View check run for this annotation

Codecov / codecov/patch

cmd/jaeger/internal/extension/jaegerstorage/extension.go#L82-L83

Added lines #L82 - L83 were not covered by tests
}

func getV2FactoryAdapter(name string, host component.Host) (*factoryadapter.Factory, error) {
f, err := GetStorageFactory(name, host)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions cmd/jaeger/internal/extension/jaegerstorage/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestStorageFactoryBadShutdownError(t *testing.T) {

func TestGetFactoryV2Error(t *testing.T) {
host := componenttest.NewNopHost()
_, err := GetStorageFactoryV2("something", host)
_, err := GetTraceStoreFactory("something", host)
require.ErrorContains(t, err, "cannot find extension")
}

Expand All @@ -112,7 +112,7 @@ func TestGetFactory(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, f)

f2, err := GetStorageFactoryV2(name, host)
f2, err := GetTraceStoreFactory(name, host)
require.NoError(t, err)
require.NotNil(t, f2)

Expand Down

0 comments on commit f43ec56

Please sign in to comment.