Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused metrics.ServiceIdx #4454

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 0 additions & 74 deletions common/metrics/common.go

This file was deleted.

3 changes: 0 additions & 3 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ type (
metricName MetricName // metric name
unit MetricUnit
}

// ServiceIdx is an index that uniquely identifies the service
ServiceIdx int
)

// MetricUnit supported values
Expand Down
11 changes: 0 additions & 11 deletions common/metrics/metric_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@

package metrics

// Service names for all services that emit metrics.
const (
Common ServiceIdx = iota
Frontend
History
Matching
Worker
Server
UnitTestService
)

// Common tags for all services
const (
OperationTagName = "operation"
Expand Down
6 changes: 1 addition & 5 deletions common/resourcetest/resourceTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ const (
var testHostInfo = membership.NewHostInfoFromAddress(testHostName)

// NewTest returns a new test resource instance
func NewTest(
controller *gomock.Controller,
serviceMetricsIndex metrics.ServiceIdx,
) *Test {
func NewTest(controller *gomock.Controller, serviceName primitives.ServiceName) *Test {
logger := log.NewTestLogger()

frontendClient := workflowservicemock.NewMockWorkflowServiceClient(controller)
Expand Down Expand Up @@ -169,7 +166,6 @@ func NewTest(
membershipMonitor.EXPECT().WaitUntilInitialized(gomock.Any()).Return(nil).AnyTimes()

scope := tally.NewTestScope("test", nil)
serviceName, _ := metrics.MetricsServiceIdxToServiceName(serviceMetricsIndex)
metricsHandler := metrics.NewTallyMetricsHandler(metrics.ClientConfig{}, scope).WithTags(
metrics.ServiceNameTag(serviceName),
)
Expand Down
4 changes: 2 additions & 2 deletions service/frontend/adminHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

"go.temporal.io/server/common/clock"
"go.temporal.io/server/common/persistence/visibility/store/standard/cassandra"
"go.temporal.io/server/common/primitives"
"go.temporal.io/server/common/resourcetest"

"google.golang.org/grpc/health"
Expand Down Expand Up @@ -62,7 +63,6 @@ import (
clientmocks "go.temporal.io/server/client"
"go.temporal.io/server/common"
"go.temporal.io/server/common/config"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/persistence/serialization"
Expand Down Expand Up @@ -120,7 +120,7 @@ func (s *adminHandlerSuite) SetupTest() {
)

s.controller = gomock.NewController(s.T())
s.mockResource = resourcetest.NewTest(s.controller, metrics.Frontend)
s.mockResource = resourcetest.NewTest(s.controller, primitives.FrontendService)
s.mockNamespaceCache = s.mockResource.NamespaceCache
s.mockHistoryClient = s.mockResource.HistoryClient
s.mockExecutionMgr = s.mockResource.ExecutionMgr
Expand Down
4 changes: 2 additions & 2 deletions service/frontend/operator_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ import (
"go.temporal.io/api/operatorservice/v1"
"go.temporal.io/api/serviceerror"
"go.temporal.io/api/workflowservice/v1"
"go.temporal.io/server/common/primitives"
"google.golang.org/grpc/health"

"go.temporal.io/server/api/adminservice/v1"
persistencespb "go.temporal.io/server/api/persistence/v1"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/persistence/visibility/store/elasticsearch"
"go.temporal.io/server/common/resourcetest"
Expand Down Expand Up @@ -83,7 +83,7 @@ func (s *operatorHandlerSuite) SetupTest() {
s.Assertions = require.New(s.T())

s.controller = gomock.NewController(s.T())
s.mockResource = resourcetest.NewTest(s.controller, metrics.Frontend)
s.mockResource = resourcetest.NewTest(s.controller, primitives.FrontendService)
s.mockResource.ClusterMetadata.EXPECT().GetCurrentClusterName().Return(uuid.New()).AnyTimes()

args := NewOperatorHandlerImplArgs{
Expand Down
2 changes: 1 addition & 1 deletion service/frontend/workflow_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *workflowHandlerSuite) SetupTest() {
s.testNamespaceID = "e4f90ec0-1313-45be-9877-8aa41f72a45a"

s.controller = gomock.NewController(s.T())
s.mockResource = resourcetest.NewTest(s.controller, metrics.Frontend)
s.mockResource = resourcetest.NewTest(s.controller, primitives.FrontendService)
s.mockNamespaceCache = s.mockResource.NamespaceCache
s.mockHistoryClient = s.mockResource.HistoryClient
s.mockClusterMetadata = s.mockResource.ClusterMetadata
Expand Down
4 changes: 2 additions & 2 deletions service/history/replication/task_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.temporal.io/server/common/primitives"

"go.temporal.io/server/api/adminservice/v1"
"go.temporal.io/server/api/adminservicemock/v1"
replicationspb "go.temporal.io/server/api/replication/v1"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/resourcetest"
"go.temporal.io/server/service/history/configs"
"go.temporal.io/server/service/history/tests"
Expand Down Expand Up @@ -84,7 +84,7 @@ func (s *taskFetcherSuite) SetupTest() {
s.Assertions = require.New(s.T())
s.controller = gomock.NewController(s.T())

s.mockResource = resourcetest.NewTest(s.controller, metrics.History)
s.mockResource = resourcetest.NewTest(s.controller, primitives.HistoryService)
s.frontendClient = s.mockResource.RemoteAdminClient
s.logger = log.NewNoopLogger()
s.config = tests.NewDynamicConfig()
Expand Down
4 changes: 2 additions & 2 deletions service/history/shard/context_testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
"fmt"

"github.com/golang/mock/gomock"
"go.temporal.io/server/common/primitives"

"go.temporal.io/server/api/historyservice/v1"
persistencespb "go.temporal.io/server/api/persistence/v1"
"go.temporal.io/server/common/clock"
"go.temporal.io/server/common/future"
"go.temporal.io/server/common/membership"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/resourcetest"
"go.temporal.io/server/service/history/configs"
Expand Down Expand Up @@ -70,7 +70,7 @@ func NewTestContext(
shardInfo *persistencespb.ShardInfo,
config *configs.Config,
) *ContextTest {
resourceTest := resourcetest.NewTest(ctrl, metrics.History)
resourceTest := resourcetest.NewTest(ctrl, primitives.HistoryService)
eventsCache := events.NewMockCache(ctrl)
hostInfoProvider := membership.NewMockHostInfoProvider(ctrl)
lifecycleCtx, lifecycleCancel := context.WithCancel(context.Background())
Expand Down
3 changes: 2 additions & 1 deletion service/history/shard/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (

"go.temporal.io/server/api/enums/v1"
persistencespb "go.temporal.io/server/api/persistence/v1"
"go.temporal.io/server/common/primitives"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -125,7 +126,7 @@ func (s *controllerSuite) SetupTest() {
s.Assertions = require.New(s.T())

s.controller = gomock.NewController(s.T())
s.mockResource = resourcetest.NewTest(s.controller, metrics.History)
s.mockResource = resourcetest.NewTest(s.controller, primitives.HistoryService)
s.mockHistoryEngine = NewMockEngine(s.controller)
s.mockEngineFactory = NewMockEngineFactory(s.controller)

Expand Down
4 changes: 2 additions & 2 deletions service/worker/scanner/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import (
"github.com/stretchr/testify/suite"
"go.temporal.io/sdk/activity"
"go.temporal.io/sdk/workflow"
"go.temporal.io/server/common/primitives"

"go.temporal.io/sdk/testsuite"
"go.temporal.io/sdk/worker"

"go.temporal.io/server/common/metrics"
p "go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/resourcetest"
)
Expand Down Expand Up @@ -77,7 +77,7 @@ func (s *scannerWorkflowTestSuite) TestScavengerActivity() {
s.registerActivities(env)
controller := gomock.NewController(s.T())
defer controller.Finish()
mockResource := resourcetest.NewTest(controller, metrics.Worker)
mockResource := resourcetest.NewTest(controller, primitives.WorkerService)

mockResource.TaskMgr.EXPECT().ListTaskQueue(gomock.Any(), gomock.Any()).Return(&p.ListTaskQueueResponse{}, nil)

Expand Down