expose vtbackup stats at --port /metrics#11388
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
If a new flag is being introduced:
If a workflow is added or modified:
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
| mysqlTimeout = 5 * time.Minute | ||
| initDBSQLFile string | ||
| detachedMode bool | ||
| keepAliveTimeout = 0 * time.Second |
There was a problem hiding this comment.
New, the rest is just formatting changes
go/cmd/vtbackup/vtbackup.go
Outdated
| } | ||
|
|
||
| func init() { | ||
| mathrand.Seed(time.Now().UnixNano()) |
There was a problem hiding this comment.
Not sure if this is needed. Copy-pasted from another cmd package.
There was a problem hiding this comment.
I don't think it's needed here.
There was a problem hiding this comment.
I don't think this is needed
| exit.Return(1) | ||
| } | ||
|
|
||
| if keepAliveTimeout > 0 { |
There was a problem hiding this comment.
Added for local testing, but think it could be useful in K8s context to keep process alive long enough for a Prometheus scrape interval.
| // Catch SIGTERM and SIGINT so we get a chance to clean up. | ||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| sigChan := make(chan os.Signal, 1) | ||
| signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) |
There was a problem hiding this comment.
Signal handling now the responsibility of servenv
f7bf347 to
5f17ded
Compare
Signed-off-by: Max Englander <max@planetscale.com>
5f17ded to
bb164b4
Compare
| func init() { | ||
| mathrand.Seed(time.Now().UnixNano()) | ||
| servenv.RegisterDefaultFlags() | ||
| dbconfigs.RegisterFlags(dbconfigs.All...) |
There was a problem hiding this comment.
Moved from main
|
|
||
| func main() { | ||
| defer exit.Recover() | ||
| dbconfigs.RegisterFlags(dbconfigs.All...) |
There was a problem hiding this comment.
Moved to init
Signed-off-by: Max Englander <max@planetscale.com>
GuptaManan100
left a comment
There was a problem hiding this comment.
All the other changes LGTM!
Signed-off-by: Max Englander <max@planetscale.com>
Description
As far as I can tell
vtbackupdoes not currently expose metrics. It would be awesome if it did. In particular it would be great to have the following timings:This PR modifies
vtbackupcommand so that a server is started on--port. The server is similar to that launched by other VT components, and includes a/metricsroute. With this PR this route include two useful metrics which are managed by themysqlctlpackage:vtbackup_restore_duration_secondsvtbackup_backup_duration_secondsKeeping this PR small to lay the groundwork. The other metrics can come in a later PR if we're OK with this overall approach.
Use cases
PlanetScale makes ongoing internal and public efforts to improve backup and restore performance. It would be great to have detailed metrics on current performance so that we can make informed decisions on where to put our energy.