-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
71875: changefeedccl: Add metrics scope library for changefeeds. r=miretskiy a=miretskiy Add a utility library that allows creation of fixed number (8) of custome "metric" scopes. Each scope is intended to keep track of a small set of SLI related metrics. Scopes are named "tier0", "tier1", ... "tier7". Follow on changes will integrate changefeed code with this library. CRDB-2422 Release Notes: None 71907: backupccl: pause backup schedule in TestFullClusterBackup r=rhu713 a=rhu713 Currently the backup schedule in TestFullClusterBackup can be processed by the job scheduler in the original DB after the backup has been taken, thus causing a difference between the original and restored clusters. Prevent this processing by setting the first run in the future and pausing the schedule. Fixes #71435 Release note: None 71909: jobs: don't block on notify r=ajwerner a=ajwerner We have a method to notify the registry to go scan for jobs. There was no reason for it to block. It did. This commit makes it not block without meaningfully changing the semantics. There are better improvements to be had by making the jobs subsystem much more targeted, but this is some serious bang for its buck in terms of speedup vs. lines changed. Release note (performance improvement): Creating many schema changes in parallel now runs faster due to improved concurrency notifying the jobs subsystem. 71938: ui: use push instead of replace on browser history on SQL Activity page r=maryliag a=maryliag Previously, when changing tabs on SQL Activity page the history would be replaced, this commits change to push to history, meaning when the user clicks Back on the browser it will return for the previous tab. Release note: None 71948: bazel: bump size of `pkg/bench/rttanalysis:rttanalysis_test` r=rail a=rickystewart Release note: none Co-authored-by: Yevgeniy Miretskiy <[email protected]> Co-authored-by: Rui Hu <[email protected]> Co-authored-by: Andrew Werner <[email protected]> Co-authored-by: Marylia Gutierrez <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
- Loading branch information
Showing
12 changed files
with
186 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// 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<number>", and each metric name | ||
// contained in SLIMetrics will be prefixed by "changefeed.tier<number" prefix. | ||
func CreateSLIScopes() *SLIScopes { | ||
scope := &SLIScopes{ | ||
names: make(map[string]*SLIMetrics, maxSLIScopes), | ||
} | ||
|
||
for i := 0; i < maxSLIScopes; i++ { | ||
scopeName := fmt.Sprintf("tier%d", i) | ||
scope.Scopes[i] = makeSLIMetrics(fmt.Sprintf("changefeed.%s", scopeName)) | ||
scope.names[scopeName] = scope.Scopes[i] | ||
} | ||
return scope | ||
} | ||
|
||
// GetSLIMetrics returns a metric.Struct associated with the specified scope, or nil | ||
// of no such scope exists. | ||
func (s *SLIScopes) GetSLIMetrics(scopeName string) *SLIMetrics { | ||
return s.names[scopeName] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// 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" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/cockroachdb/cockroach/pkg/util/metric" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMetricScope(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
scope := CreateSLIScopes() | ||
require.NotNil(t, scope) | ||
|
||
sliMetricNames := []string{ | ||
"error_retries", | ||
} | ||
|
||
expectedMetrics := make(map[string]struct{}) | ||
expectScopedMetrics := func(scope string) { | ||
for _, n := range sliMetricNames { | ||
expectedMetrics[fmt.Sprintf("changefeed.%s.%s", scope, n)] = struct{}{} | ||
} | ||
} | ||
|
||
for i := 0; i < maxSLIScopes; i++ { | ||
scopeName := fmt.Sprintf("tier%d", i) | ||
require.NotNil(t, scope.GetSLIMetrics(scopeName)) | ||
expectScopedMetrics(scopeName) | ||
} | ||
|
||
require.Nil(t, scope.GetSLIMetrics("does not exist")) | ||
require.Nil(t, scope.GetSLIMetrics(fmt.Sprintf("tier%d", maxSLIScopes+1))) | ||
|
||
registry := metric.NewRegistry() | ||
registry.AddMetricStruct(scope) | ||
registry.Each(func(name string, _ interface{}) { | ||
_, exists := expectedMetrics[name] | ||
require.True(t, exists) | ||
delete(expectedMetrics, name) | ||
}) | ||
require.Equal(t, 0, len(expectedMetrics), | ||
"remaining metrics: %s", expectedMetrics) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters