-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Deprecate old metrics in VTOrc and replace with new ones #15994
Deprecate old metrics in VTOrc and replace with new ones #15994
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
We discussed this offline, but documenting for wider visibility. Metric names in code should actually be PascalCase, that is the convention that >99% of existing metrics use. We have a conversion to snake case before they are exported to the |
…ed names and use them Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
249ba76
to
dc92968
Compare
Signed-off-by: Manan Gupta <manan@planetscale.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15994 +/- ##
==========================================
- Coverage 68.47% 68.27% -0.21%
==========================================
Files 1562 1562
Lines 197083 197204 +121
==========================================
- Hits 134962 134634 -328
- Misses 62121 62570 +449 ☔ View full report in Codecov by Sentry. |
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.
Looks fine to me for now. My questions are more around what happens in v21, and whether we can (and should) delete the new functions after v20.
Two other things:
- it will be good for @dbussink to review this
- we need a follow up PR for the reparent counters (added in
vtctld
/vtorc
: improve reparenting stats #13723) that are showing up as snake_case instead of PascalCase in debug/vars, and add @timvaillancourt as a reviewer on that one.
@@ -36,7 +36,8 @@ import ( | |||
"vitess.io/vitess/go/vt/vtorc/util" | |||
) | |||
|
|||
var analysisChangeWriteCounter = stats.NewCounter("analysis.change.write", "Number of times analysis has changed") | |||
// The metric is registered with a deprecated name. The old metric name can be removed in v21. | |||
var analysisChangeWriteCounter = stats.NewCounterWithDeprecatedName("AnalysisChangeWrite", "analysis.change.write", "Number of times analysis has changed") |
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.
What would we do in v21? We have two options: either revert to using NewCounter with the new name, or replace the old name with empty string while still calling the new function.
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.
Also, can/should we delete these new functions in v21?
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.
I think we should revert to NewCounter
and remove the functions. That would be cleaner.
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.
@GuptaManan100 agreed, seems like the cleanest and matches then how we do it for other stuff.
Description
This PR deprecates the names for some old metrics and replace with new ones. Since the new metric names and the old metric names resolved to the same snake case name in prometheus, just adding a new metric was causing a panic because of re-registration of a metric with the same name.
This PR resolves this issue by creating 2 new helper functions in
stats
package calledNewCounterWithDeprecatedName
andNewGaugeWithDeprecatedName
which register metrics with a name and a deprecated name. They only publish one to prometheus (or other registered backend), while still exporting both to expvar.This allows for us to have both the metrics new and old available on the
debug/vars
page. Since the 2 metrics resolve to the same name for prometheus, even when we remove the old metrics, nothing will change there.Related Issue(s)
Checklist
Deployment Notes