Skip to content

⚠️ Make all metrics opt-in #1589

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

Closed
wants to merge 1 commit into from
Closed

⚠️ Make all metrics opt-in #1589

wants to merge 1 commit into from

Conversation

2uasimojo
Copy link
Contributor

This commit stops registering metrics by default. Consumers may now register them explicitly via two newly-exported methods:

import (
	crmetrics "sigs.k8s.io/controller-runtime/metrics"
)

func init() {
	crmetrics.RegisterClientMetrics()
	crmetrics.RegisterReflectorMetrics()
}

Each of these methods accepts varargs to opt out of any of the metrics it is responsible for. For example:

crmetrics.RegisterClientMetrics(crmetrics.LatencyKey)

This will still register rest_client_requests_total, but will avoid
registering rest_client_request_latency_seconds.

fixes: #1423

This commit stops registering metrics by default. Consumers may now
register them explicitly via two newly-exported methods:

```go
import (
	crmetrics "sigs.k8s.io/controller-runtime/metrics"
)

func init() {
	crmetrics.RegisterClientMetrics()
	crmetrics.RegisterReflectorMetrics()
}
```

Each of these methods accepts varargs to opt *out* of any of the metrics
it is responsible for. For example:

```go
crmetrics.RegisterClientMetrics(crmetrics.LatencyKey)
```

This will still register `rest_client_requests_total`, but will avoid
registering `rest_client_request_latency_seconds`.
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 9, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 2uasimojo
To complete the pull request process, please assign gerred after the PR has been reviewed.
You can assign the PR to them by writing /assign @gerred in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Hi @2uasimojo. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 9, 2021
@2uasimojo
Copy link
Contributor Author

/close

We're going to do #1587 instead, but I wanted to get this out of my brain.

@k8s-ci-robot
Copy link
Contributor

@2uasimojo: Closed this PR.

In response to this:

/close

We're going to do #1587 instead, but I wanted to get this out of my brain.

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/test-infra repository.

@2uasimojo 2uasimojo deleted the issues/1423/all-opt-in branch July 9, 2021 16:36
registerReflectorMetrics()
}
// RegisterClientMetrics sets up the client latency metrics from client-go.
// To opt *out* of specific metrics, specify their *Key consts to optOut.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Realistically this is lousy UX without a better indication that the varargs are opt out rather than in. It would probably be better to flip it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable rest client latency metric
2 participants