From 9a187e02e45caa73520291047cee5d9d05b55a06 Mon Sep 17 00:00:00 2001 From: Yevgeniy Miretskiy Date: Sat, 30 Oct 2021 08:31:47 -0400 Subject: [PATCH] changefeedccl: Remove metrics scope library. Remove metrics scope library since it has been moved under changefeedccl. Note: this is a move only refactoring, but it is structured as 2 changes (one to add new files, and one to remove cdcutils files) so that it can be easily backported. Release Notes: None --- pkg/ccl/changefeedccl/cdcutils/BUILD.bazel | 11 +-- .../changefeedccl/cdcutils/metrics_scope.go | 77 ------------------- .../cdcutils/metrics_scope_test.go | 57 -------------- 3 files changed, 2 insertions(+), 143 deletions(-) delete mode 100644 pkg/ccl/changefeedccl/cdcutils/metrics_scope.go delete mode 100644 pkg/ccl/changefeedccl/cdcutils/metrics_scope_test.go diff --git a/pkg/ccl/changefeedccl/cdcutils/BUILD.bazel b/pkg/ccl/changefeedccl/cdcutils/BUILD.bazel index a9dfffd76a83..993c43479b4e 100644 --- a/pkg/ccl/changefeedccl/cdcutils/BUILD.bazel +++ b/pkg/ccl/changefeedccl/cdcutils/BUILD.bazel @@ -2,10 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "cdcutils", - srcs = [ - "metrics_scope.go", - "throttle.go", - ], + srcs = ["throttle.go"], importpath = "github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/cdcutils", visibility = ["//visibility:public"], deps = [ @@ -21,17 +18,13 @@ go_library( go_test( name = "cdcutils_test", - srcs = [ - "metrics_scope_test.go", - "throttle_test.go", - ], + srcs = ["throttle_test.go"], embed = [":cdcutils"], deps = [ "//pkg/ccl/changefeedccl/changefeedbase", "//pkg/settings/cluster", "//pkg/util/leaktest", "//pkg/util/log", - "//pkg/util/metric", "@com_github_stretchr_testify//require", ], ) diff --git a/pkg/ccl/changefeedccl/cdcutils/metrics_scope.go b/pkg/ccl/changefeedccl/cdcutils/metrics_scope.go deleted file mode 100644 index a69430dbe54a..000000000000 --- a/pkg/ccl/changefeedccl/cdcutils/metrics_scope.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2021 The Cockroach Authors. -// -// Licensed as a CockroachDB Enterprise file under the Cockroach Community -// License (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt - -package cdcutils - -import ( - "fmt" - - "github.com/cockroachdb/cockroach/pkg/util/metric" -) - -// maxSLIScopes is a static limit on the number of SLI scopes -- that is the number -// of SLI metrics we will keep track of. -// The limit is static due to metric.Registry limitations. -const maxSLIScopes = 8 - -// SLIMetrics is the list of SLI related metrics for changefeeds. -type SLIMetrics struct { - ErrorRetries *metric.Counter - // TODO(yevgeniy): Add more SLI related metrics. -} - -// MetricStruct implements metric.Struct interface -func (*SLIMetrics) MetricStruct() {} - -func makeSLIMetrics(prefix string) *SLIMetrics { - withPrefix := func(meta metric.Metadata) metric.Metadata { - meta.Name = fmt.Sprintf("%s.%s", prefix, meta.Name) - return meta - } - - return &SLIMetrics{ - ErrorRetries: metric.NewCounter(withPrefix(metric.Metadata{ - Name: "error_retries", - Help: "Total retryable errors encountered this SLI", - Measurement: "Errors", - Unit: metric.Unit_COUNT, - })), - } -} - -// SLIScopes represents a set of SLI related metrics for a particular "scope". -type SLIScopes struct { - Scopes [maxSLIScopes]*SLIMetrics // Exported so that we can register w/ metrics registry. - names map[string]*SLIMetrics -} - -// MetricStruct implements metric.Struct interface -func (*SLIScopes) MetricStruct() {} - -// CreateSLIScopes creates changefeed specific SLI scope: a metric.Struct containing -// SLI specific metrics for each scope. -// The scopes are statically named "tier", and each metric name -// contained in SLIMetrics will be prefixed by "changefeed.tier