Skip to content

Commit

Permalink
Remove Namespacing And Add Close Call To Decorator
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Nov 29, 2024
1 parent e29e5db commit fb0ecae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion storage/storagemetrics/decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package storagemetrics

import (
"io"

"go.uber.org/zap"

"github.com/jaegertracing/jaeger/pkg/metrics"
Expand All @@ -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,
}
}

Expand All @@ -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
}
2 changes: 1 addition & 1 deletion storage/storagemetrics/decorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fb0ecae

Please sign in to comment.