Skip to content
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

Merged
merged 3 commits into from
May 28, 2024

Conversation

GuptaManan100
Copy link
Member

@GuptaManan100 GuptaManan100 commented May 22, 2024

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 called NewCounterWithDeprecatedName and NewGaugeWithDeprecatedName 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.
Screenshot 2024-05-23 at 1 14 47 PM
Screenshot 2024-05-23 at 1 15 05 PM

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Copy link
Contributor

vitess-bot bot commented May 22, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels May 22, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone May 22, 2024
@deepthi
Copy link
Member

deepthi commented May 22, 2024

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 /metrics endpoint.
Unfortunately, this is more of a naming convention than something that is enforced by a linter or CI check, so a few have slipped through that are named differently from the majority.

…ed names and use them

Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
@GuptaManan100 GuptaManan100 added Type: Internal Cleanup Component: VTorc Vitess Orchestrator integration and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels May 23, 2024
@GuptaManan100 GuptaManan100 marked this pull request as ready for review May 23, 2024 07:45
Signed-off-by: Manan Gupta <manan@planetscale.com>
Copy link

codecov bot commented May 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.27%. Comparing base (3b09eb2) to head (0798f5c).
Report is 11 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@deepthi deepthi left a 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:

@@ -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")
Copy link
Member

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

@deepthi deepthi requested a review from dbussink May 24, 2024 16:35
@GuptaManan100 GuptaManan100 merged commit 0c2856e into vitessio:main May 28, 2024
93 checks passed
@GuptaManan100 GuptaManan100 deleted the deprecate-vtorc-metrics branch May 28, 2024 15:34
Ari1009 pushed a commit to Ari1009/vitess that referenced this pull request Jun 2, 2024
)

Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Ari1009 <arihant0pal@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VTorc Vitess Orchestrator integration Type: Internal Cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants