From fb0ecaedf6eea163ecd1c1d6949dc8c70ac00db0 Mon Sep 17 00:00:00 2001 From: Mahad Zaryab Date: Fri, 29 Nov 2024 11:47:33 -0500 Subject: [PATCH] Remove Namespacing And Add Close Call To Decorator Signed-off-by: Mahad Zaryab --- storage/storagemetrics/decorator.go | 11 ++++++++++- storage/storagemetrics/decorator_test.go | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/storage/storagemetrics/decorator.go b/storage/storagemetrics/decorator.go index 99c1691f356..187e790e829 100644 --- a/storage/storagemetrics/decorator.go +++ b/storage/storagemetrics/decorator.go @@ -4,6 +4,8 @@ package storagemetrics import ( + "io" + "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/metrics" @@ -21,7 +23,7 @@ type DecoratorFactory struct { func NewDecoratorFactory(f storage.Factory, mf metrics.Factory) *DecoratorFactory { return &DecoratorFactory{ delegate: f, - metricsFactory: mf.Namespace(metrics.NSOptions{Name: "storage"}), + metricsFactory: mf, } } @@ -45,3 +47,10 @@ func (df *DecoratorFactory) CreateSpanWriter() (spanstore.Writer, error) { func (df *DecoratorFactory) CreateDependencyReader() (dependencystore.Reader, error) { return df.delegate.CreateDependencyReader() } + +func (df *DecoratorFactory) Close() error { + if closer, ok := df.delegate.(io.Closer); ok { + return closer.Close() + } + return nil +} diff --git a/storage/storagemetrics/decorator_test.go b/storage/storagemetrics/decorator_test.go index 1f1983daab6..362ef4d1b2f 100644 --- a/storage/storagemetrics/decorator_test.go +++ b/storage/storagemetrics/decorator_test.go @@ -57,7 +57,7 @@ func TestCreateSpanReader_ReturnsDecoratedReader(t *testing.T) { expectedReader.On("GetServices", context.Background()).Return([]string{}, nil) r.GetServices(context.Background()) counters, _ := mf.Snapshot() - require.EqualValues(t, map[string]int64{"storage.requests|operation=get_services|result=ok": 1}, counters) + require.EqualValues(t, map[string]int64{"requests|operation=get_services|result=ok": 1}, counters) } func TestCreateSpanWriter_DelegatesUnderlyingResponse(t *testing.T) {