Skip to content

Commit

Permalink
Deprecate per service metrics config (#2546)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ardagan authored Feb 25, 2022
1 parent 9964786 commit f7952b4
Show file tree
Hide file tree
Showing 42 changed files with 222 additions and 295 deletions.
2 changes: 1 addition & 1 deletion common/archiver/gcloud/historyArchiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (h *historyArchiverSuite) SetupTest() {
h.controller = gomock.NewController(h.T())
h.container = &archiver.HistoryBootstrapContainer{
Logger: log.NewNoopLogger(),
MetricsClient: metrics.NewNoopMetricsClient(),
MetricsClient: metrics.NoopClient,
}
h.testArchivalURI, _ = archiver.NewURI("gs://my-bucket-cad/temporal_archival/development")
}
Expand Down
2 changes: 1 addition & 1 deletion common/archiver/gcloud/visibilityArchiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s *visibilityArchiverSuite) SetupTest() {
s.controller = gomock.NewController(s.T())
s.container = &archiver.VisibilityBootstrapContainer{
Logger: log.NewNoopLogger(),
MetricsClient: metrics.NewNoopMetricsClient(),
MetricsClient: metrics.NoopClient,
}
s.expectedVisibilityRecords = []*archiverspb.VisibilityRecord{
{
Expand Down
2 changes: 0 additions & 2 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ type (
Service struct {
// RPC is the rpc configuration
RPC RPC `yaml:"rpc"`
// Deprecated. Use Metrics in global section instead.
Metrics metrics.Config `yaml:"metrics"`
}

// PProf contains the config items for the pprof utility
Expand Down
158 changes: 158 additions & 0 deletions common/metrics/noop_impl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package metrics

import (
"time"

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

var (
NoopReporter Reporter = newNoopReporter()
NoopClient Client = newNoopClient()
noopInternalScope internalScope = newNoopScope()
NoopScope Scope = noopInternalScope
NoopUserScope UserScope = newNoopUserScope()
NoopStopwatch Stopwatch = newNoopStopwatch()
)

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

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

func (_ *noopReporterImpl) NewClient(logger log.Logger, serviceIdx ServiceIdx) (Client, error) {
return NoopClient, nil
}

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, 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{}
}

func (m *noopClientImpl) IncCounter(scope int, counter int) {}

func (m *noopClientImpl) AddCounter(scope int, counter int, delta int64) {}

func (m *noopClientImpl) StartTimer(scope int, timer int) Stopwatch {
return NoopStopwatch
}

func (m *noopClientImpl) RecordTimer(scope int, timer int, d time.Duration) {}

func (m *noopClientImpl) RecordDistribution(scope int, timer int, d int) {}

func (m *noopClientImpl) UpdateGauge(scope int, gauge int, value float64) {}

func (m *noopClientImpl) Scope(scope int, tags ...Tag) Scope {
return NoopScope
}

func (m *noopClientImpl) UserScope() UserScope {
return NoopUserScope
}

// NoopScope returns a noop scope of metrics
func newNoopScope() internalScope {
return &noopScopeImpl{}
}

func (n *noopScopeImpl) AddCounterInternal(name string, delta int64) {
}

func (n *noopScopeImpl) StartTimerInternal(timer string) Stopwatch {
return NoopStopwatch
}

func (n *noopScopeImpl) RecordTimerInternal(timer string, d time.Duration) {
}

func (n *noopScopeImpl) RecordDistributionInternal(id string, unit MetricUnit, d int) {
}

func (n *noopScopeImpl) TaggedInternal(tags ...Tag) internalScope {
return n
}

func (n *noopScopeImpl) IncCounter(counter int) {}

func (n *noopScopeImpl) AddCounter(counter int, delta int64) {}

func (n *noopScopeImpl) StartTimer(timer int) Stopwatch {
return NoopStopwatch
}

func (n *noopScopeImpl) RecordTimer(timer int, d time.Duration) {}

func (n *noopScopeImpl) RecordDistribution(id int, d int) {}

func (n *noopScopeImpl) UpdateGauge(gauge int, value float64) {}

func (n *noopScopeImpl) Tagged(tags ...Tag) Scope {
return n
}

// NopStopwatch return a fake tally stop watch
func newNoopStopwatch() *noopStopwatchImpl {
return &noopStopwatchImpl{}
}

func (n *noopStopwatchImpl) Stop() {}
func (n *noopStopwatchImpl) Subtract(nsec time.Duration) {}
105 changes: 0 additions & 105 deletions common/metrics/noop_metrics_client.go

This file was deleted.

73 changes: 0 additions & 73 deletions common/metrics/noop_scope.go

This file was deleted.

Loading

0 comments on commit f7952b4

Please sign in to comment.