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

feat: clear_metrics #16550

Closed
wants to merge 3 commits into from
Closed

feat: clear_metrics #16550

wants to merge 3 commits into from

Conversation

wlx5575
Copy link
Contributor

@wlx5575 wlx5575 commented Aug 7, 2024

Description

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

Copy link
Contributor

vitess-bot bot commented Aug 7, 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 Aug 7, 2024
@github-actions github-actions bot added this to the v21.0.0 milestone Aug 7, 2024
Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 3.57143% with 27 lines in your changes missing coverage. Please review.

Project coverage is 68.77%. Comparing base (27f2d73) to head (d5459a7).
Report is 98 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtgate/vtgate.go 0.00% 22 Missing ⚠️
go/vt/vtgate/scatter_conn.go 16.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16550      +/-   ##
==========================================
+ Coverage   68.75%   68.77%   +0.01%     
==========================================
  Files        1556     1556              
  Lines      199806   199831      +25     
==========================================
+ Hits       137384   137431      +47     
+ Misses      62422    62400      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @wlx5575 ! As noted, we'll need to use a different API.

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to do it differently as this package is not and should not be tied to vtgate in any direct way as it's used by all commands/binaries which publish metrics:

❯ git grep go/stats/prometheusbackend | cat
go/cmd/mysqlctl/command/plugin_prometheusbackend.go:	"vitess.io/vitess/go/stats/prometheusbackend"
go/cmd/mysqlctld/cli/plugin_prometheusbackend.go:	"vitess.io/vitess/go/stats/prometheusbackend"
go/cmd/vtbackup/cli/plugin_prometheusbackend.go:	"vitess.io/vitess/go/stats/prometheusbackend"
go/cmd/vtctld/cli/plugin_prometheusbackend.go:	"vitess.io/vitess/go/stats/prometheusbackend"
go/cmd/vtgate/cli/plugin_prometheusbackend.go:	"vitess.io/vitess/go/stats/prometheusbackend"
go/cmd/vtorc/cli/plugin_prometheusbackend.go:	"vitess.io/vitess/go/stats/prometheusbackend"
go/cmd/vttablet/cli/plugin_prometheusbackend.go:	"vitess.io/vitess/go/stats/prometheusbackend"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback!could you please suggest where it would be more appropriate to place this API? I can make adjustments based on your suggestion.

Copy link
Contributor

@mattlord mattlord Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want this to be for vtgate then add it to vtgate. If you want it to be generic then the stats package has a global dynamic registry of stats that could be reset (and either way, this has nothing specifically to do with the prometheus backend).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VTGate:

vtgateInst.registerDebugHealthHandler()
vtgateInst.registerDebugEnvHandler()

Comment on lines 102 to 103
} else {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the ELSE and we can remove the whitespace. If statsName is empty we return. So we can simply return after that IF block as well.

@mattlord mattlord added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Observability Pull requests that touch tracing/metrics/monitoring and removed NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Aug 7, 2024
@wlx5575
Copy link
Contributor Author

wlx5575 commented Aug 8, 2024

#16550 (review)

Thank you, @wlx5575 ! As noted, we'll need to use a different API.

Could you also please create a quick issue that lays out the use case for this that you had noted in Slack?

Thanks!

@mattlord mattlord removed the NeedsIssue A linked issue is missing for this Pull Request label Aug 8, 2024
Comment on lines +219 to +234
func ClearMetrics() {
vschemaCounters.ResetAll()
errorCounts.ResetAll()
warnings.ResetAll()
vstreamSkewDelayCount.Reset()
vindexUnknownParams.Reset()
timings.Reset()
rowsReturned.ResetAll()
rowsAffected.ResetAll()
queriesProcessed.ResetAll()
queriesRouted.ResetAll()
queriesProcessedByTable.ResetAll()
queriesRoutedByTable.ResetAll()
vttabletTimings.Reset()
tabletCallErrorCount.ResetAll()
}
Copy link
Contributor

@mattlord mattlord Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a problem because 1) this does not include the full list of vtgate stats today 2) when new ones are added in the future it will not be clear (or expected) to have to find this and add the new stat here for the reset.

Copy link
Contributor

github-actions bot commented Sep 8, 2024

This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:

  • Push additional commits to the associated branch.
  • Remove the stale label.
  • Add a comment indicating why it is not stale.

If no action is taken within 7 days, this PR will be closed.

@github-actions github-actions bot added the Stale Marks PRs as stale after a period of inactivity, which are then closed after a grace period. label Sep 8, 2024
Copy link
Contributor

This PR was closed because it has been stale for 7 days with no activity.

@github-actions github-actions bot closed this Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Observability Pull requests that touch tracing/metrics/monitoring NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says Stale Marks PRs as stale after a period of inactivity, which are then closed after a grace period. Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: Request for API to Clear Gateway Monitoring Data on Port 15001
2 participants