Skip to content

Commit

Permalink
Remove reporter and userscope interfaces (#3044)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreiding authored Jun 30, 2022
1 parent c7866bb commit d968a39
Show file tree
Hide file tree
Showing 28 changed files with 82 additions and 597 deletions.
32 changes: 0 additions & 32 deletions common/metrics/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import (
"time"

"github.com/uber-go/tally/v4"

"go.temporal.io/server/common/log"
)

type (
Expand Down Expand Up @@ -90,36 +88,6 @@ type (
// information to metrics
Tagged(tags ...Tag) Scope
}

// UserScope is an interface for reporting metrics by user code
// Deprecated
UserScope interface {
// IncCounter increments a counter metric
IncCounter(counter string)
// AddCounter adds delta to the counter metric
AddCounter(counter string, delta int64)
// StartTimer starts a timer for the given metric name.
// Time will be recorded when stopwatch is stopped.
StartTimer(timer string) Stopwatch
// RecordTimer records a timer for the given metric name
RecordTimer(timer string, d time.Duration)
// RecordDistribution records a distribution (wrapper on top of timer) for the given
// metric name
RecordDistribution(id string, unit MetricUnit, d int)
// UpdateGauge reports Gauge type absolute value metric
UpdateGauge(gauge string, value float64)
// Tagged returns a new scope with added and/or overriden tags values that can be used
// to provide additional information to metrics
Tagged(tags map[string]string) UserScope
}

// Reporter is an interface for base constructor for metrics client.
// Deprecated
Reporter interface {
MetricsHandler() MetricsHandler
Stop(logger log.Logger)
UserScope() UserScope
}
)

var sanitizer = tally.NewSanitizer(tally.SanitizeOptions{
Expand Down
175 changes: 0 additions & 175 deletions common/metrics/interfaces_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 4 additions & 44 deletions common/metrics/noop_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,59 +31,19 @@ import (
)

var (
NoopReporter Reporter = newNoopReporter()
NoopClient Client = newNoopClient()
NoopScope Scope = newNoopScope()
NoopUserScope UserScope = newNoopUserScope()
NoopStopwatch Stopwatch = newNoopStopwatch()
NoopMetricsHandler MetricsHandler = newNoopMetricsHandler()
)

type (
noopReporterImpl struct{}
noopClientImpl struct{}
noopMetricsUserScope struct{}
noopStopwatchImpl struct{}
noopScopeImpl struct{}
noopMetricsHandler struct{}
noopClientImpl struct{}
noopStopwatchImpl struct{}
noopScopeImpl struct{}
noopMetricsHandler struct{}
)

func newNoopReporter() *noopReporterImpl {
return &noopReporterImpl{}
}

func (*noopReporterImpl) MetricsHandler() MetricsHandler {
return NoopMetricsHandler
}

func (*noopReporterImpl) Stop(logger log.Logger) {}

func (*noopReporterImpl) UserScope() UserScope {
return NoopUserScope
}

func newNoopUserScope() *noopMetricsUserScope {
return &noopMetricsUserScope{}
}

func (n *noopMetricsUserScope) IncCounter(counter string) {}

func (n *noopMetricsUserScope) AddCounter(counter string, delta int64) {}

func (n *noopMetricsUserScope) StartTimer(timer string) Stopwatch {
return NoopStopwatch
}

func (n *noopMetricsUserScope) RecordTimer(timer string, d time.Duration) {}

func (n *noopMetricsUserScope) RecordDistribution(id string, unit MetricUnit, d int) {}

func (n *noopMetricsUserScope) UpdateGauge(gauge string, value float64) {}

func (n *noopMetricsUserScope) Tagged(tags map[string]string) UserScope {
return n
}

func newNoopClient() *noopClientImpl {
return &noopClientImpl{}
}
Expand Down
File renamed without changes.
File renamed without changes.
53 changes: 0 additions & 53 deletions common/metrics/reporter.go

This file was deleted.

Loading

0 comments on commit d968a39

Please sign in to comment.