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

Fix bug in bucket key calculation #1279

Merged
merged 2 commits into from May 28, 2023
Merged

Fix bug in bucket key calculation #1279

merged 2 commits into from May 28, 2023

Conversation

beorn7
Copy link
Member

@beorn7 beorn7 commented May 25, 2023

The current code doesn't work fork negative schemas if the observed
value should go into a bucket with a non-positive key.

In the 1st commit, tests are added to expose the bug.

In the 2st commit, the bug is fixed. The expression smells a bit like it should be possible to simplify. But I couldn't come up with a simpler form. Let me know if you have any ideas.

The current code doesn't work fork negative schemas if the observed
value should go into a bucket with a non-positive key.

Signed-off-by: beorn7 <beorn@grafana.com>
The current code doesn't work fork negative schemas if the observed
value should go into a bucket with a non-positive key.

Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7
Copy link
Member Author

beorn7 commented May 25, 2023

So you could write the two-liner as key = (key + (1 << -schema) - 1) >> -schema.

If you inverted the sign of schema first, it would look more benign:

key = (key + (1 << schema) - 1) >> schema

I thought this is a perfect thing to throw at ChatGPT:

image

That's obviously garbage. Just in case anyone was afraid to lose their job…

@beorn7
Copy link
Member Author

beorn7 commented May 25, 2023

The fun thing is that you can argue with ChatGPT:

image

So the improvement is that the "simplified" expression is actually less simple but also still wrong… 🤣

Copy link
Member

@fstab fstab left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix. I ran a brute force test with random numbers and it's all green now.

@beorn7 beorn7 merged commit 5e78d5f into main May 28, 2023
8 checks passed
@beorn7 beorn7 deleted the beorn7/histogram branch May 28, 2023 22:09
renovate bot added a commit to open-feature/flagd that referenced this pull request Jun 15, 2023
….0 (#709)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/prometheus/client_golang](https://togithub.com/prometheus/client_golang)
| require | minor | `v1.15.1` -> `v1.16.0` |

---

### Release Notes

<details>
<summary>prometheus/client_golang</summary>

###
[`v1.16.0`](https://togithub.com/prometheus/client_golang/releases/tag/v1.16.0)

[Compare
Source](https://togithub.com/prometheus/client_golang/compare/v1.15.1...v1.16.0)

#### What's Changed

- \[BUGFIX] api: Switch to POST for LabelNames, Series, and
QueryExemplars.
[#&#8203;1252](https://togithub.com/prometheus/client_golang/issues/1252)
- \[BUGFIX] api: Fix undefined execution order in return statements.
[#&#8203;1260](https://togithub.com/prometheus/client_golang/issues/1260)
- \[BUGFIX] native histograms: Fix bug in bucket key calculation.
[#&#8203;1279](https://togithub.com/prometheus/client_golang/issues/1279)
- \[ENHANCEMENT] Reduce constrainLabels allocations for all metrics.
[#&#8203;1272](https://togithub.com/prometheus/client_golang/issues/1272)
- \[ENHANCEMENT] promhttp: Add process start time header for scrape
efficiency.
[#&#8203;1278](https://togithub.com/prometheus/client_golang/issues/1278)
- \[ENHANCEMENT] promlint: Improve metricUnits runtime.
[#&#8203;1286](https://togithub.com/prometheus/client_golang/issues/1286)

<details>
  <summary> Commits </summary>

- Merge v1.15 to main by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1250
- Switch to POST for LabelNames, Series, and QueryExemplars to
DoGetFallback by [@&#8203;jacksontj](https://togithub.com/jacksontj) in
[prometheus/client_golang#1252
- ✏️ \[collectors]: fix typo in test assertion by
[@&#8203;vegerot](https://togithub.com/vegerot) in
[prometheus/client_golang#1153
- Added interactive tutorial \[kubeCon] by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1255
- Fixed tutorial. by [@&#8203;bwplotka](https://togithub.com/bwplotka)
in
[prometheus/client_golang#1256
- Bump golang.org/x/sys from 0.6.0 to 0.7.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1265
- Cleanup proto use in tests by
[@&#8203;SuperQ](https://togithub.com/SuperQ) in
[prometheus/client_golang#1264
- Fix tutorial on WSL-based systems by
[@&#8203;marevers](https://togithub.com/marevers) in
[prometheus/client_golang#1257
- Fix undefined execution order in return statements by
[@&#8203;PiotrLewandowski323](https://togithub.com/PiotrLewandowski323)
in
[prometheus/client_golang#1260
- Merge release 1.15.1 to main by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1267
- GitHub Workflows security hardening by
[@&#8203;sashashura](https://togithub.com/sashashura) in
[prometheus/client_golang#1180
- add process start time header to client_golang prometheus by
[@&#8203;logicalhan](https://togithub.com/logicalhan) in
[prometheus/client_golang#1278
- Fix bug in bucket key calculation by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1279
- Bump github.com/prometheus/procfs from 0.9.0 to 0.10.1 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1283
- Reduce constrainLabels allocations by
[@&#8203;khasanovbi](https://togithub.com/khasanovbi) in
[prometheus/client_golang#1272
- added circleci as gh action YAML by
[@&#8203;krishnaduttPanchagnula](https://togithub.com/krishnaduttPanchagnula)
in
[prometheus/client_golang#1281
- Improve metricUnits runtime by
[@&#8203;avlitman](https://togithub.com/avlitman) in
[prometheus/client_golang#1286
- Moving fully to GH actions. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1288
- Fix docstring references to renamed native histogram fields /
functions. by [@&#8203;juliusv](https://togithub.com/juliusv) in
[prometheus/client_golang#1290
- Fixed README & CHANGELOG; Added fmt makefile command (+bingo) for
easier contributions. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1289
-

 </details>

#### New Contributors
* @&#8203;vegerot made their first
contributi[prometheus/client_golang#1153
* @&#8203;marevers made their first
contributi[prometheus/client_golang#1257
* @&#8203;PiotrLewandowski323 made their first
contributi[prometheus/client_golang#1260
* @&#8203;sashashura made their first
contributi[prometheus/client_golang#1180
* @&#8203;logicalhan made their first
contributi[prometheus/client_golang#1278
* @&#8203;khasanovbi made their first
contributi[prometheus/client_golang#1272
* @&#8203;krishnaduttPanchagnula made their first
contributi[prometheus/client_golang#1281
* @&#8203;avlitman made their first
contributi[prometheus/client_golang#1286

**Full Changelog**:
prometheus/client_golang@v1.15.1...v1.16.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/open-feature/flagd).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMTcuMyIsInVwZGF0ZWRJblZlciI6IjM1LjExNy4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
apricote pushed a commit to hetznercloud/hcloud-cloud-controller-manager that referenced this pull request Jun 16, 2023
)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/prometheus/client_golang](https://togithub.com/prometheus/client_golang)
| require | minor | `v1.15.1` -> `v1.16.0` |

---

### Release Notes

<details>
<summary>prometheus/client_golang</summary>

###
[`v1.16.0`](https://togithub.com/prometheus/client_golang/releases/tag/v1.16.0)

[Compare
Source](https://togithub.com/prometheus/client_golang/compare/v1.15.1...v1.16.0)

#### What's Changed

- \[BUGFIX] api: Switch to POST for LabelNames, Series, and
QueryExemplars.
[#&#8203;1252](https://togithub.com/prometheus/client_golang/issues/1252)
- \[BUGFIX] api: Fix undefined execution order in return statements.
[#&#8203;1260](https://togithub.com/prometheus/client_golang/issues/1260)
- \[BUGFIX] native histograms: Fix bug in bucket key calculation.
[#&#8203;1279](https://togithub.com/prometheus/client_golang/issues/1279)
- \[ENHANCEMENT] Reduce constrainLabels allocations for all metrics.
[#&#8203;1272](https://togithub.com/prometheus/client_golang/issues/1272)
- \[ENHANCEMENT] promhttp: Add process start time header for scrape
efficiency.
[#&#8203;1278](https://togithub.com/prometheus/client_golang/issues/1278)
- \[ENHANCEMENT] promlint: Improve metricUnits runtime.
[#&#8203;1286](https://togithub.com/prometheus/client_golang/issues/1286)

<details>
  <summary> Commits </summary>

- Merge v1.15 to main by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1250
- Switch to POST for LabelNames, Series, and QueryExemplars to
DoGetFallback by [@&#8203;jacksontj](https://togithub.com/jacksontj) in
[prometheus/client_golang#1252
- ✏️ \[collectors]: fix typo in test assertion by
[@&#8203;vegerot](https://togithub.com/vegerot) in
[prometheus/client_golang#1153
- Added interactive tutorial \[kubeCon] by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1255
- Fixed tutorial. by [@&#8203;bwplotka](https://togithub.com/bwplotka)
in
[prometheus/client_golang#1256
- Bump golang.org/x/sys from 0.6.0 to 0.7.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1265
- Cleanup proto use in tests by
[@&#8203;SuperQ](https://togithub.com/SuperQ) in
[prometheus/client_golang#1264
- Fix tutorial on WSL-based systems by
[@&#8203;marevers](https://togithub.com/marevers) in
[prometheus/client_golang#1257
- Fix undefined execution order in return statements by
[@&#8203;PiotrLewandowski323](https://togithub.com/PiotrLewandowski323)
in
[prometheus/client_golang#1260
- Merge release 1.15.1 to main by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1267
- GitHub Workflows security hardening by
[@&#8203;sashashura](https://togithub.com/sashashura) in
[prometheus/client_golang#1180
- add process start time header to client_golang prometheus by
[@&#8203;logicalhan](https://togithub.com/logicalhan) in
[prometheus/client_golang#1278
- Fix bug in bucket key calculation by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1279
- Bump github.com/prometheus/procfs from 0.9.0 to 0.10.1 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1283
- Reduce constrainLabels allocations by
[@&#8203;khasanovbi](https://togithub.com/khasanovbi) in
[prometheus/client_golang#1272
- added circleci as gh action YAML by
[@&#8203;krishnaduttPanchagnula](https://togithub.com/krishnaduttPanchagnula)
in
[prometheus/client_golang#1281
- Improve metricUnits runtime by
[@&#8203;avlitman](https://togithub.com/avlitman) in
[prometheus/client_golang#1286
- Moving fully to GH actions. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1288
- Fix docstring references to renamed native histogram fields /
functions. by [@&#8203;juliusv](https://togithub.com/juliusv) in
[prometheus/client_golang#1290
- Fixed README & CHANGELOG; Added fmt makefile command (+bingo) for
easier contributions. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1289
-

 </details>

#### New Contributors
* @&#8203;vegerot made their first
contributi[prometheus/client_golang#1153
* @&#8203;marevers made their first
contributi[prometheus/client_golang#1257
* @&#8203;PiotrLewandowski323 made their first
contributi[prometheus/client_golang#1260
* @&#8203;sashashura made their first
contributi[prometheus/client_golang#1180
* @&#8203;logicalhan made their first
contributi[prometheus/client_golang#1278
* @&#8203;khasanovbi made their first
contributi[prometheus/client_golang#1272
* @&#8203;krishnaduttPanchagnula made their first
contributi[prometheus/client_golang#1281
* @&#8203;avlitman made their first
contributi[prometheus/client_golang#1286

**Full Changelog**:
prometheus/client_golang@v1.15.1...v1.16.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/hetznercloud/hcloud-cloud-controller-manager).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMTcuMyIsInVwZGF0ZWRJblZlciI6IjM1LjExNy4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
nono added a commit to cozy/cozy-stack that referenced this pull request Jun 19, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/prometheus/client_golang](https://togithub.com/prometheus/client_golang)
| require | minor | `v1.15.1` -> `v1.16.0` |

---

### Release Notes

<details>
<summary>prometheus/client_golang</summary>

###
[`v1.16.0`](https://togithub.com/prometheus/client_golang/releases/tag/v1.16.0)

#### What's Changed

- \[BUGFIX] api: Switch to POST for LabelNames, Series, and
QueryExemplars.
[#&#8203;1252](https://togithub.com/prometheus/client_golang/issues/1252)
- \[BUGFIX] api: Fix undefined execution order in return statements.
[#&#8203;1260](https://togithub.com/prometheus/client_golang/issues/1260)
- \[BUGFIX] native histograms: Fix bug in bucket key calculation.
[#&#8203;1279](https://togithub.com/prometheus/client_golang/issues/1279)
- \[ENHANCEMENT] Reduce constrainLabels allocations for all metrics.
[#&#8203;1272](https://togithub.com/prometheus/client_golang/issues/1272)
- \[ENHANCEMENT] promhttp: Add process start time header for scrape
efficiency.
[#&#8203;1278](https://togithub.com/prometheus/client_golang/issues/1278)
- \[ENHANCEMENT] promlint: Improve metricUnits runtime.
[#&#8203;1286](https://togithub.com/prometheus/client_golang/issues/1286)

<details>
  <summary> Commits </summary>

- Merge v1.15 to main by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1250
- Switch to POST for LabelNames, Series, and QueryExemplars to
DoGetFallback by [@&#8203;jacksontj](https://togithub.com/jacksontj) in
[prometheus/client_golang#1252
- ✏️ \[collectors]: fix typo in test assertion by
[@&#8203;vegerot](https://togithub.com/vegerot) in
[prometheus/client_golang#1153
- Added interactive tutorial \[kubeCon] by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1255
- Fixed tutorial. by [@&#8203;bwplotka](https://togithub.com/bwplotka)
in
[prometheus/client_golang#1256
- Bump golang.org/x/sys from 0.6.0 to 0.7.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1265
- Cleanup proto use in tests by
[@&#8203;SuperQ](https://togithub.com/SuperQ) in
[prometheus/client_golang#1264
- Fix tutorial on WSL-based systems by
[@&#8203;marevers](https://togithub.com/marevers) in
[prometheus/client_golang#1257
- Fix undefined execution order in return statements by
[@&#8203;PiotrLewandowski323](https://togithub.com/PiotrLewandowski323)
in
[prometheus/client_golang#1260
- Merge release 1.15.1 to main by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1267
- GitHub Workflows security hardening by
[@&#8203;sashashura](https://togithub.com/sashashura) in
[prometheus/client_golang#1180
- add process start time header to client_golang prometheus by
[@&#8203;logicalhan](https://togithub.com/logicalhan) in
[prometheus/client_golang#1278
- Fix bug in bucket key calculation by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1279
- Bump github.com/prometheus/procfs from 0.9.0 to 0.10.1 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1283
- Reduce constrainLabels allocations by
[@&#8203;khasanovbi](https://togithub.com/khasanovbi) in
[prometheus/client_golang#1272
- added circleci as gh action YAML by
[@&#8203;krishnaduttPanchagnula](https://togithub.com/krishnaduttPanchagnula)
in
[prometheus/client_golang#1281
- Improve metricUnits runtime by
[@&#8203;avlitman](https://togithub.com/avlitman) in
[prometheus/client_golang#1286
- Moving fully to GH actions. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1288
- Fix docstring references to renamed native histogram fields /
functions. by [@&#8203;juliusv](https://togithub.com/juliusv) in
[prometheus/client_golang#1290
- Fixed README & CHANGELOG; Added fmt makefile command (+bingo) for
easier contributions. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1289
-

 </details>

#### New Contributors
* @&#8203;vegerot made their first
contributi[prometheus/client_golang#1153
* @&#8203;marevers made their first
contributi[prometheus/client_golang#1257
* @&#8203;PiotrLewandowski323 made their first
contributi[prometheus/client_golang#1260
* @&#8203;sashashura made their first
contributi[prometheus/client_golang#1180
* @&#8203;logicalhan made their first
contributi[prometheus/client_golang#1278
* @&#8203;khasanovbi made their first
contributi[prometheus/client_golang#1272
* @&#8203;krishnaduttPanchagnula made their first
contributi[prometheus/client_golang#1281
* @&#8203;avlitman made their first
contributi[prometheus/client_golang#1286

**Full Changelog**:
prometheus/client_golang@v1.15.1...v1.16.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am on Monday" in timezone
Europe/Paris, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/cozy/cozy-stack).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMjYuMCIsInVwZGF0ZWRJblZlciI6IjM1LjEyNi4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants