-
Notifications
You must be signed in to change notification settings - Fork 200
Support proxy_server_ready_backends metric #754
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
Support proxy_server_ready_backends metric #754
Conversation
Hi @maqiuyujoyce. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test Did you consider using ProxyStrategy in the new metric? It would be nice to keep *Manager and *Storage types as implementation details. The proxy server already exposes --proxy-strategies to the cluster admin. |
pkg/server/metrics/metrics.go
Outdated
@@ -284,6 +299,11 @@ func (s *ServerMetrics) SetBackendCount(count int) { | |||
s.backend.WithLabelValues().Set(float64(count)) | |||
} | |||
|
|||
// SetTotalBackendCount sets the total number of backend connection. | |||
func (s *ServerMetrics) SetTotalBackendCount(managerName string, count int) { | |||
s.totalBackendCount.WithLabelValues(managerName).Set(float64(count)) |
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.
Labels can generate cardinality issues. I don't think this is likely to be a problem but we can reassure/protect ourselves by changing managerName from a string (unbounded cardinality) to an enumeration with an observation on limiting the number of options.
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.
Done.
Based on @jkh52 's suggestion above, I used proxy strategy enum as the label. (Thank you @jkh52 !)
It introduced the circular dependency, so I extracted out ProxyStrategy related types and functions into a separate package, and many files were updated. I can split it out into a separate PR if you prefer!
I think there will remain a bug in |
e72d63b
to
565867c
Compare
Done. |
@jkh52 Also moved the tests into this PR according to your suggestion. Please take a look! |
pkg/server/metrics/metrics.go
Outdated
prometheus.GaugeOpts{ | ||
Namespace: Namespace, | ||
Subsystem: Subsystem, | ||
Name: "ready_backend_connections_total", |
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.
Final concern: the _total suffix here seems to contradict prometheus naming conventions (it implies a counter metric, not gauge).
Maybe just "ready_backends" or similar?
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.
Done.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jkh52, maqiuyujoyce The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #294
Prior art: #295
Added a new metric to track the total number of backends based on proxy strategy. To avoid circular import, I extracted out ProxyStrategy related types, functions and tests into a separate package.
I didn't overwrite the existent
proxy_server_ready_backend_connections
metric because of potential backwards compatibility concern brought up here: https://github.com/kubernetes-sigs/apiserver-network-proxy/pull/295/files#r872839718 Instead, I marked the problematicproxy_server_ready_backend_connections
metric deprecated in the help message.Tested locally following this example and got the following result when supporting both default and desthost backend managers:
Added unit tests for the new metric as well.