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

📖 document exposed metrics #811

Merged
merged 1 commit into from
Mar 2, 2020

Conversation

djzager
Copy link
Contributor

@djzager djzager commented Feb 20, 2020

Update documentation for the metrics package to enumerate all exposed
metrics with an explanation of what they capture.

Fixes #262

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 20, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @djzager. 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 Feb 20, 2020
@djzager
Copy link
Contributor Author

djzager commented Feb 20, 2020

I see that the original comment was referring to the pkg/webhook/internal/metrics package but it already documents the exposed metrics.

I could follow the same pattern as pkg/webhook/internal/metrics but that would require exporting a bunch of stuff that is currently not exported.

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/ok-to-test
/assign @DirectXMan12
/lgtm

@vincepri vincepri added this to the v0.5.x milestone Feb 21, 2020
@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 21, 2020
@djzager
Copy link
Contributor Author

djzager commented Feb 21, 2020

Looking around the project at the other metrics packages (ie. controller metrics and webhook metrics) I feel that I took the wrong approach in this PR.

What I would like to do would be to export the variables in this package where metrics are defined (making them var where they are now hidden inside a function) and add the appropriate comments.

@DirectXMan12 @vincepri WDYT?

@vincepri
Copy link
Member

That sounds good to me as well

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 21, 2020
// This file is copied and adapted from k8s.io/kubernetes/pkg/util/workqueue/prometheus
// which registers metrics to the default prometheus Registry. We require very
// similar functionality, but must register metrics to a different Registry.

var (
// WorkQueueSubsystem defines the subsystem for the workqueue metrics.
WorkQueueSubsystem = "workqueue"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

went ahead and followed what was being done in kubernetes metrics

@djzager
Copy link
Contributor Author

djzager commented Feb 21, 2020

Went ahead and left it as 2 commits to make it easier to go back to the original if necessary. If this works I'll rebase and squash.

@DirectXMan12
Copy link
Contributor

DirectXMan12 commented Feb 26, 2020

Hey, so I'm sorry to jump in a bit later here, but:

What I would like to do would be to export the variables in this package where metrics are defined (making them var where they are now hidden inside a function) and add the appropriate comments.

Due to the way this is currently structured, it means we have out metrics compatibility boundary not at the metrics we expose, but via the exact method we expose them by. For instance, under this model, switching to OpenTelemetry is necessarily a breaking change, even if we expose the same metrics in the same format with the same names, since the Go types change. Considering that the Go types are mostly an implementation detail, that seems suboptimal.

Should be easy to fix by moving the actual variables into an internal package, like the other referenced examples.

EDIT: looked a the linked examples, clarified what I said a bit.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 26, 2020
Update documentation for the metrics package to enumerate all exposed
metrics with an explanation of what they capture.
@djzager
Copy link
Contributor Author

djzager commented Feb 26, 2020

Due to the way this is currently structured, it means we have out metrics compatibility boundary not at the metrics we expose, but via the exact method we expose them by. For instance, under this model, switching to OpenTelemetry is necessarily a breaking change, even if we expose the same metrics in the same format with the same names, since the Go types change. Considering that the Go types are mostly an implementation detail, that seems suboptimal.

My idea of making unexported vars exported made me uneasy, but I didn't really understand why. Thank you for the explanation.

I have updated the metrics package to expose the subsystems and specific keys used without exporting the metrics themselves.

I would be tempted to make similar changes in https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/webhook/internal/metrics/metrics.go and https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/internal/controller/metrics/metrics.go but I suspect making exported things unexported would also be a breaking change. It's also possible that pkg/internal/controller/metrics and pkg/webhook/internal/metrics are fundamentally different than pkg/metrics but I'm not certain. Hoping to gain better understanding of what changes make sense and when.

@DirectXMan12
Copy link
Contributor

It's also possible that pkg/internal/controller/metrics and pkg/webhook/internal/metrics are fundamentally different than pkg/metrics but I'm not certain

Ah, yes, your intuition is correct here :-). In Go, and package with /internal/ in the path as visibility limited to the parent package of /internal (as well as any subpackages of the parent package). So anything in /pkg/webhook/internal/... can only be accessed by things in /pkg/webhook/.... This is enforced by the compiler's import logic: https://golang.org/doc/go1.4#internalpackages

@DirectXMan12
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 26, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12, djzager

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2020
@shawn-hurley
Copy link

Should we cancel the hold on this?

@vincepri
Copy link
Member

vincepri commented Mar 2, 2020

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 2, 2020
@k8s-ci-robot k8s-ci-robot merged commit fd64b8f into kubernetes-sigs:master Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document what metrics are registered in godoc
5 participants