Skip to content

Commit

Permalink
Address Feedback From PR Review
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
  • Loading branch information
mahadzaryab1 committed Nov 29, 2024
1 parent f8192a0 commit 6f678c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 54 deletions.
59 changes: 15 additions & 44 deletions cmd/jaeger/internal/extension/jaegerstorage/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ func newStorageExt(config *Config, telset component.TelemetrySettings) *storageE
func (s *storageExt) Start(_ context.Context, host component.Host) error {
telset := telemetry.FromOtelComponent(s.telset, host)
telset.Metrics = telset.Metrics.Namespace(metrics.NSOptions{Name: "jaeger"})
getMetricsFactory := func(name, kind string) metrics.Factory {
return telset.Metrics.Namespace(metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"name": name,
"kind": kind,
},
})
}
for storageName, cfg := range s.config.TraceBackends {
s.telset.Logger.Sugar().Infof("Initializing storage '%s'", storageName)
var factory storage.Factory
Expand All @@ -125,73 +134,35 @@ func (s *storageExt) Start(_ context.Context, host component.Host) error {
case cfg.Memory != nil:
factory, err = memory.NewFactoryWithConfig(
*cfg.Memory,
telset.Metrics.Namespace(metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"name": storageName,
"kind": "memory",
},
}),
getMetricsFactory(storageName, "memory"),
s.telset.Logger,
), nil
case cfg.Badger != nil:
factory, err = badger.NewFactoryWithConfig(
*cfg.Badger,
telset.Metrics.Namespace(metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"name": storageName,
"kind": "badger",
},
}),
getMetricsFactory(storageName, "badger"),
s.telset.Logger)
case cfg.GRPC != nil:
grpcTelset := telset
grpcTelset.Metrics = grpcTelset.Metrics.Namespace(
metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"name": storageName,
"kind": "grpc",
},
},
)
grpcTelset.Metrics = getMetricsFactory(storageName, "grpc")
//nolint: contextcheck
factory, err = grpc.NewFactoryWithConfig(*cfg.GRPC, grpcTelset)
case cfg.Cassandra != nil:
factory, err = cassandra.NewFactoryWithConfig(
*cfg.Cassandra,
telset.Metrics.Namespace(metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"name": storageName,
"kind": "cassandra",
},
}),
getMetricsFactory(storageName, "cassandra"),
s.telset.Logger,
)
case cfg.Elasticsearch != nil:
factory, err = es.NewFactoryWithConfig(
*cfg.Elasticsearch,
telset.Metrics.Namespace(metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"name": storageName,
"kind": "elasticsearch",
},
}),
getMetricsFactory(storageName, "elasticsearch"),
s.telset.Logger,
)
case cfg.Opensearch != nil:
factory, err = es.NewFactoryWithConfig(
*cfg.Opensearch,
telset.Metrics.Namespace(metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"name": storageName,
"kind": "opensearch",
},
}),
getMetricsFactory(storageName, "opensearch"),
s.telset.Logger,
)
}
Expand Down
18 changes: 8 additions & 10 deletions plugin/storage/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,14 @@ func (*Factory) getFactoryOfType(factoryType string) (storage.Factory, error) {
// Initialize implements storage.Factory.
func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error {
f.metricsFactory = metricsFactory
for name, factory := range f.factories {
if err := factory.Initialize(
metricsFactory.Namespace(metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"name": name,
// TODO: how should we get kind?
},
}),
logger); err != nil {
for kind, factory := range f.factories {
mf := metricsFactory.Namespace(metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"kind": kind,
},
})
if err := factory.Initialize(mf, logger); err != nil {
return err
}
}
Expand Down

0 comments on commit 6f678c5

Please sign in to comment.