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

[WIP] Add sampling histogram #94672

Closed

Conversation

MikeSpreitzer
Copy link
Member

@MikeSpreitzer MikeSpreitzer commented Sep 10, 2020

What type of PR is this?

/kind cleanup

What this PR does / why we need it:
In https://github.com/kubernetes/apiserver/blob/master/pkg/util/flowcontrol/metrics/sample_and_watermark.go today there is the abstraction of sampling a variable to populate a histogram. It has an awkward bit of code: a loop to call the Observe method of a Prometheus Histogram a variable number of times. This led to the suggestion prometheus/client_golang#796 . The discussion there suggested I create a new Prometheus abstraction, possibly out of (prometheus) tree. This PR is my start on such a creation, indeed out of the prometheus tree.

There are three bits of tension here:

  1. The support for "vectors" of metrics in the Prometheus golang library is not public --- and it is non-trivial. This makes doing this work out of the prometheus tree problematic.
  2. sampling-histogram_test.go uses fake clocks. That's the only reasonable way to get sufficient control in a test that runs quickly. But the Prometheus tree does not include such clocks, so moving this code into the Prometheus tree would be problematic.
  3. sample_and_watermark.go traffics in passive clocks (and with good reason: to support event-based testing of API Priority and Fairness code), but k8s.io/utils/clock does not define passive clocks.

Which issue(s) this PR fixes:

Fixes prometheus/client_golang#796

Special notes for your reviewer:
For the moment I put a personal copyright on the code that could go in either Kubernetes or Prometheus, depending on how the relevant tensions are relaxed.

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


This covers SamplingHistogram but not SamplingHistogramVec (because
the vec support of prometheus is not public).
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 10, 2020
@MikeSpreitzer
Copy link
Member Author

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 10, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MikeSpreitzer
To complete the pull request process, please assign bentheelder, serathius
You can assign the PR to them by writing /assign @bentheelder @serathius 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

Before this change, the staticcheck test in the pull-kubernetes-verify
job complained about some possible nil pointer dereferences, but those
would never happen because `t.Errorf` aborts the test.  Added control
flow (that will never be reached, if you understand `t.Errorf`) to
make it obvious that the nil dereferences will never happen.
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Sep 12, 2020

@MikeSpreitzer: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-verify bbb0cf5 link /test pull-kubernetes-verify

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@MikeSpreitzer
Copy link
Member Author

/test pull-kubernetes-bazel-test

@MikeSpreitzer
Copy link
Member Author

This is waiting on prometheus/client_golang#803 to merge.

@MikeSpreitzer
Copy link
Member Author

kubernetes/utils#190 is going to be important

@beorn7
Copy link

beorn7 commented Oct 15, 2020

prometheus/client_golang#803 is merged now. Sorry for the delay. I'll cut a release v1.8.0 of prometheus/client_golang today so you don't need to lock to a particular commit in your go.mod file anymore.

If you need help with what I said about implementing a more efficient sampling histogram, let me know. For example, I could create a PR on top of this, once it is merged (or even before, if you prefer that).

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 13, 2021
@beorn7
Copy link

beorn7 commented Jan 13, 2021

As this has gone stale now, let me repeat my offer above to help implementing my suggestion. Let me know if that's something you would appreciate.

@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 12, 2021
@MikeSpreitzer
Copy link
Member Author

/remove-lifecycle rotten
Yes, @beorn7 , thanks for your offer, I am interested. Just a little swamped now and slow on getting things done.

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Feb 12, 2021
@beorn7
Copy link

beorn7 commented Feb 15, 2021

OK, I'll try to propose something in the next few days.

@beorn7
Copy link

beorn7 commented Feb 26, 2021

@MikeSpreitzer I created a PR against your fork to demonstrate my proposal.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 6, 2021
@k8s-ci-robot
Copy link
Contributor

@MikeSpreitzer: PR needs rebase.

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.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 5, 2021
@k8s-triage-robot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 4, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. 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.

Feature Request: Permit histogram's Observe() method to take an observation count
5 participants