-
Notifications
You must be signed in to change notification settings - Fork 2.3k
metrics: change vtbackup_duration_by_phase to binary-valued vtbackup_phase #12973
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
Merged
GuptaManan100
merged 12 commits into
vitessio:main
from
planetscale:maxeng-rework-vtbackup-phase-stats
Sep 20, 2023
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
19a1176
go/cmd: vtbackup_duration_by_phase => vtbackup_phase
maxenglander a2bbaa3
update release notes
maxenglander 3d076ff
send stats to file during vtbackup test, verify afterwards
maxenglander 8a7e559
update flags
maxenglander 8e759c9
use stats.Variable iface instead expvar.Var
maxenglander 19e1e32
try fix upgrade/downgrade test
maxenglander ad61e10
Revert "update release notes"
maxenglander ff22dc3
update v18 release notes
maxenglander 93c4852
Merge branch 'main' into maxeng-rework-vtbackup-phase-stats
maxenglander 706716f
merge <- main
maxenglander fb5fe50
deprecate not deletE
maxenglander d8e54a3
CatchUpReplication -> CatchupReplication
maxenglander File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,25 @@ | ||
| /* | ||
| Copyright 2023 The Vitess Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import "vitess.io/vitess/go/stats/opentsdb" | ||
|
|
||
| // This plugin imports opentsdb to register the opentsdb stats backend. | ||
|
|
||
| func init() { | ||
| opentsdb.Init("vtbackup") | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -321,6 +321,29 @@ func (g *GaugesWithSingleLabel) Set(name string, value int64) { | |
| g.counters.set(name, value) | ||
| } | ||
|
|
||
| // SyncGaugesWithSingleLabel is a GaugesWithSingleLabel that proactively pushes | ||
|
||
| // stats to push-based backends when Set is called. | ||
| type SyncGaugesWithSingleLabel struct { | ||
| GaugesWithSingleLabel | ||
| name string | ||
| } | ||
|
|
||
| // NewSyncGaugesWithSingleLabel creates a new SyncGaugesWithSingleLabel. | ||
| func NewSyncGaugesWithSingleLabel(name, help, label string, tags ...string) *SyncGaugesWithSingleLabel { | ||
| return &SyncGaugesWithSingleLabel{ | ||
| GaugesWithSingleLabel: *NewGaugesWithSingleLabel(name, help, label, tags...), | ||
| name: name, | ||
| } | ||
| } | ||
|
|
||
| // Set sets the value of a named gauge. | ||
| func (sg *SyncGaugesWithSingleLabel) Set(name string, value int64) { | ||
| sg.GaugesWithSingleLabel.Set(name, value) | ||
| if sg.name != "" { | ||
| _ = pushOne(sg.name, &sg.GaugesWithSingleLabel) | ||
| } | ||
| } | ||
|
|
||
| // GaugesWithMultiLabels is a CountersWithMultiLabels implementation where | ||
| // the values can go up and down. | ||
| type GaugesWithMultiLabels struct { | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -121,6 +121,22 @@ func Publish(name string, v expvar.Var) { | |
| publish(name, v) | ||
| } | ||
|
|
||
| func pushAll() error { | ||
| backend, ok := pushBackends[statsBackend] | ||
| if !ok { | ||
| return fmt.Errorf("no PushBackend registered with name %s", statsBackend) | ||
| } | ||
| return backend.PushAll() | ||
| } | ||
|
|
||
| func pushOne(name string, v Variable) error { | ||
| backend, ok := pushBackends[statsBackend] | ||
| if !ok { | ||
| return fmt.Errorf("no PushBackend registered with name %s", statsBackend) | ||
| } | ||
| return backend.PushOne(name, v) | ||
| } | ||
|
|
||
| // StringMapFuncWithMultiLabels is a multidimensional string map publisher. | ||
| // | ||
| // Map keys are compound names made with joining multiple strings with '.', | ||
|
|
@@ -183,8 +199,10 @@ func publish(name string, v expvar.Var) { | |
| // to be pushed to it. It's used to support push-based metrics backends, as expvar | ||
| // by default only supports pull-based ones. | ||
| type PushBackend interface { | ||
| // PushAll pushes all stats from expvar to the backend | ||
| // PushAll pushes all stats from expvar to the backend. | ||
| PushAll() error | ||
| // PushOne pushes a single stat from expvar to the backend. | ||
| PushOne(name string, v Variable) error | ||
| } | ||
|
|
||
| var pushBackends = make(map[string]PushBackend) | ||
|
|
@@ -214,13 +232,7 @@ func emitToBackend(emitPeriod *time.Duration) { | |
| ticker := time.NewTicker(*emitPeriod) | ||
| defer ticker.Stop() | ||
| for range ticker.C { | ||
| backend, ok := pushBackends[statsBackend] | ||
|
||
| if !ok { | ||
| log.Errorf("No PushBackend registered with name %s", statsBackend) | ||
| return | ||
| } | ||
| err := backend.PushAll() | ||
| if err != nil { | ||
| if err := pushAll(); err != nil { | ||
| // TODO(aaijazi): This might cause log spam... | ||
| log.Warningf("Pushing stats to backend %v failed: %v", statsBackend, err) | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to test for vtbackup-specific metrics in an E2E test, used opentsdb plugin and write stats to file for later verification.