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

Add possibility to dynamically get label values for http instrumentation #1066

Merged
merged 1 commit into from Jan 19, 2023

Conversation

Okhoshi
Copy link
Contributor

@Okhoshi Okhoshi commented Jun 16, 2022

Signed-off-by: Quentin Devos 4972091+Okhoshi@users.noreply.github.com

I need to partition the metrics generated by promhttp by the value coming in a specific header, and while I appreciate the design of promhttp is made to be simple and cover only the base use cases, it would be great if we could have a bit more of flexibility.

It would also give a way to solve #491 elegantly while letting the user control the cardinality of the label they add.

@bwplotka @kakkoyun

@Okhoshi
Copy link
Contributor Author

Okhoshi commented Aug 25, 2022

Gently repinging @bwplotka and @kakkoyun for a review of this PR ?

Let me know if it doesn't have any chance to be merged, so that I don't wait for it 👍

Also, I saw it's quite similar to #1104, probably share the same concern (that user can now add as many label values as it wants) but I also have the same thought than @chradcliffe on the fact that a user is knowingly added a high cardinality label by using the option, and therefore it's not promhttp responsibility.

Note that I could work with #1104 even though using context would force me to add another middleware to push request/response value into the context.

@Okhoshi Okhoshi force-pushed the dynamiclabelhttp branch 2 times, most recently from 004d7e3 to 50f10d3 Compare August 25, 2022 10:29
@Okhoshi
Copy link
Contributor Author

Okhoshi commented Aug 25, 2022

I added a way to constraint the values any dynamic label can take, such that the cardinality has to be known in advance. Would that address your concerns @bwplotka ?

Copy link
Member

@bwplotka bwplotka 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 this!

I think with more and more requests to add dynamic labels to promhttp - we should do it.

I like your idea for enforcing label values, but it might be better to have something built-in metric so the same enforcing or categorization logic can be reused across anyone who uses prometheus.Observer or prometheus.Adder

With this direction, I would be happy with solutions like yours or #1104 to add dynamic labels without verification.

As per ctx vs pointers structs, the ctx will be safer for this library in some sense but tedious for users... I think I would favour your idea (but perhaps separate for client and server?) Read only thing is nice, but there is more risk for users to add new middleware, makes they you don't forget to add it and put the correct context value that does not conflict and test etc, than risk of someone modifying the request or response in their e.g. dynLabelValues(req, resp) []string

prometheus/promhttp/instrument_client.go Outdated Show resolved Hide resolved
prometheus/promhttp/option.go Outdated Show resolved Hide resolved
prometheus/promhttp/option.go Outdated Show resolved Hide resolved
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Looks good, just some ideas for more explicit naming, WDYT?

Also tests fail 🤗

prometheus/promhttp/option.go Outdated Show resolved Hide resolved
prometheus/promhttp/option.go Outdated Show resolved Hide resolved
prometheus/promhttp/option.go Outdated Show resolved Hide resolved
Signed-off-by: Quentin Devos <4972091+Okhoshi@users.noreply.github.com>
@Okhoshi
Copy link
Contributor Author

Okhoshi commented Jan 12, 2023

Looks good, just some ideas for more explicit naming, WDYT?

That naming is way better than mine 💯 Changed.

Also tests fail 🤗

Yes, something weird about not being able to find some git references 🤷

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM, solid work. Thanks for patience 💪🏽 (:

@bwplotka bwplotka merged commit fcdc3ec into prometheus:main Jan 19, 2023
@Okhoshi Okhoshi deleted the dynamiclabelhttp branch January 20, 2023 08:12
@jcass8695
Copy link

Hey gang, I was wondering if there was any estimate on when there could be a release cut with this PR included? My team are keen to use this great feature. TIA 😌

@kakkoyun
Copy link
Member

kakkoyun commented Feb 9, 2023

Hey gang, I was wondering if there was any estimate on when there could be a release cut with this PR included? My team are keen to use this great feature. TIA 😌

Hey @jcass8695, I think it's been a while since the last time we released it. Considering there's also a new Golang version, I think we can update our language support and then take a release. So it will be soon. I think it's better to wait for the Go 1.20.1 release, though.

apricote pushed a commit to hetznercloud/hcloud-cloud-controller-manager that referenced this pull request Apr 13, 2023
….0 (#424)

[![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.14.0` -> `v1.15.0` |

---

### Release Notes

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

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

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

#### Changed

\[BUGFIX] Fix issue with atomic variables on ppc64le
[#&#8203;1171](https://togithub.com/prometheus/client_golang/issues/1171)
\[BUGFIX] Support for multiple samples within same metric
[#&#8203;1181](https://togithub.com/prometheus/client_golang/issues/1181)
\[BUGFIX] Bump golang.org/x/text to v0.3.8 to mitigate CVE-2022-32149
[#&#8203;1187](https://togithub.com/prometheus/client_golang/issues/1187)
\[ENHANCEMENT] Add exemplars and middleware examples
[#&#8203;1173](https://togithub.com/prometheus/client_golang/issues/1173)
\[ENHANCEMENT] Add more context to "duplicate label names" error to
enable debugging
[#&#8203;1177](https://togithub.com/prometheus/client_golang/issues/1177)
\[ENHANCEMENT] Add constrained labels and constrained variant for all
MetricVecs
[#&#8203;1151](https://togithub.com/prometheus/client_golang/issues/1151)
\[ENHANCEMENT] Moved away from deprecated github.com/golang/protobuf
package
[#&#8203;1183](https://togithub.com/prometheus/client_golang/issues/1183)
\[ENHANCEMENT] Add possibility to dynamically get label values for http
instrumentation
[#&#8203;1066](https://togithub.com/prometheus/client_golang/issues/1066)
\[ENHANCEMENT] Add ability to Pusher to add custom headers
[#&#8203;1218](https://togithub.com/prometheus/client_golang/issues/1218)
\[ENHANCEMENT] api: Extend and improve efficiency of json-iterator usage
[#&#8203;1225](https://togithub.com/prometheus/client_golang/issues/1225)
\[ENHANCEMENT] Added (official) support for go 1.20
[#&#8203;1234](https://togithub.com/prometheus/client_golang/issues/1234)
\[ENHANCEMENT] timer: Added support for exemplars
[#&#8203;1233](https://togithub.com/prometheus/client_golang/issues/1233)
\[ENHANCEMENT] Filter expected metrics as well in CollectAndCompare
[#&#8203;1143](https://togithub.com/prometheus/client_golang/issues/1143)
\[ENHANCEMENT] ⚠️ Only set start/end if time is not Zero. This breaks
compatibility in experimental api package. If you strictly depend on
empty time.Time as actual value, the behavior is now changed
[#&#8203;1238](https://togithub.com/prometheus/client_golang/issues/1238)

<details>
  <summary>All commits</summary>

- Merge release 1.14 to main by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1164
- Fix typo in doc comment by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1166
- Fix issue with atomic variables on ppc64le by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1171
- examples: Add exemplars and middleware examples by
[@&#8203;jessicalins](https://togithub.com/jessicalins) in
[prometheus/client_golang#1173
- Add context to "duplicate label names" to enable debugging by
[@&#8203;SpencerMalone](https://togithub.com/SpencerMalone) in
[prometheus/client_golang#1177
- Add constrained labels and Constrained variant for all MetricVecs by
[@&#8203;Okhoshi](https://togithub.com/Okhoshi) in
[prometheus/client_golang#1151
- Support for multiple samples within same metric by
[@&#8203;machadovilaca](https://togithub.com/machadovilaca) in
[prometheus/client_golang#1181
- Replace deprecated github.com/golang/protobuf package by
[@&#8203;zhsj](https://togithub.com/zhsj) in
[prometheus/client_golang#1183
- Bump golang.org/x/text to v0.3.8 to mitigate CVE-2022-32149 by
[@&#8203;b4bay](https://togithub.com/b4bay) in
[prometheus/client_golang#1187
- typo fix by
[@&#8203;ibreakthecloud](https://togithub.com/ibreakthecloud) in
[prometheus/client_golang#1178
- Add possibility to dynamically get label values for http
instrumentation by [@&#8203;Okhoshi](https://togithub.com/Okhoshi) in
[prometheus/client_golang#1066
- Bump github.com/cespare/xxhash/v2 from 2.1.2 to 2.2.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1199
- Bump github.com/prometheus/procfs from 0.8.0 to 0.9.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1198
- Bump golang.org/x/sys from 0.3.0 to 0.4.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1217
- Synchronize common files from prometheus/prometheus by
[@&#8203;prombot](https://togithub.com/prombot) in
[prometheus/client_golang#1213
- Bump github.com/prometheus/common from 0.37.0 to 0.39.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1197
- Add `Header` method to Pusher for custom header by
[@&#8203;songjiayang](https://togithub.com/songjiayang) in
[prometheus/client_golang#1218
- Synchronize common files from prometheus/prometheus by
[@&#8203;prombot](https://togithub.com/prombot) in
[prometheus/client_golang#1224
- api: Extend and improve json-iterator usage by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1225
- Indent example in godoc consistently by
[@&#8203;lamida](https://togithub.com/lamida) in
[prometheus/client_golang#1226
- Remove unnecessary check if label is nil in observeWithExemplar by
[@&#8203;dimonl](https://togithub.com/dimonl) in
[prometheus/client_golang#1235
- README: Remove not working gocoverage images. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1236
- Added support for go 1.20. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1234
- timer: Added support for exemplars. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1233
- Synchronize common files from prometheus/prometheus by
[@&#8203;prombot](https://togithub.com/prombot) in
[prometheus/client_golang#1237
- Filter expected metrics as well in CollectAndCompare by
[@&#8203;DariaKunoichi](https://togithub.com/DariaKunoichi) in
[prometheus/client_golang#1143
- Only set start/end if time is not Zero by
[@&#8203;jacksontj](https://togithub.com/jacksontj) in
[prometheus/client_golang#1238
- Bump google.golang.org/protobuf from 1.28.1 to 1.30.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1243
- Bump golang.org/x/sys from 0.5.0 to 0.6.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1246
- Bump github.com/golang/protobuf from 1.5.2 to 1.5.3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1245
- Bump github.com/prometheus/common from 0.41.0 to 0.42.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1244
- Cut v1.15.0 by [@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1249

</details>

#### New Contributors
* @&#8203;SpencerMalone made their first
contributi[prometheus/client_golang#1177
* @&#8203;Okhoshi made their first
contributi[prometheus/client_golang#1151
* @&#8203;machadovilaca made their first
contributi[prometheus/client_golang#1181
* @&#8203;b4bay made their first
contributi[prometheus/client_golang#1187
* @&#8203;ibreakthecloud made their first
contributi[prometheus/client_golang#1178
* @&#8203;songjiayang made their first
contributi[prometheus/client_golang#1218
* @&#8203;lamida made their first
contributi[prometheus/client_golang#1226
* @&#8203;dimonl made their first
contributi[prometheus/client_golang#1235
* @&#8203;DariaKunoichi made their first
contributi[prometheus/client_golang#1143

**Full Changelog**:
prometheus/client_golang@v1.14.0...v1.15.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:eyJjcmVhdGVkSW5WZXIiOiIzNS40MC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNDAuMCJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot added a commit to open-feature/flagd that referenced this pull request Apr 14, 2023
….0 (#608)

[![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.14.0` -> `v1.15.0` |

---

### Release Notes

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

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

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

#### Changed

\[BUGFIX] Fix issue with atomic variables on ppc64le
[#&#8203;1171](https://togithub.com/prometheus/client_golang/issues/1171)
\[BUGFIX] Support for multiple samples within same metric
[#&#8203;1181](https://togithub.com/prometheus/client_golang/issues/1181)
\[BUGFIX] Bump golang.org/x/text to v0.3.8 to mitigate CVE-2022-32149
[#&#8203;1187](https://togithub.com/prometheus/client_golang/issues/1187)
\[ENHANCEMENT] Add exemplars and middleware examples
[#&#8203;1173](https://togithub.com/prometheus/client_golang/issues/1173)
\[ENHANCEMENT] Add more context to "duplicate label names" error to
enable debugging
[#&#8203;1177](https://togithub.com/prometheus/client_golang/issues/1177)
\[ENHANCEMENT] Add constrained labels and constrained variant for all
MetricVecs
[#&#8203;1151](https://togithub.com/prometheus/client_golang/issues/1151)
\[ENHANCEMENT] Moved away from deprecated github.com/golang/protobuf
package
[#&#8203;1183](https://togithub.com/prometheus/client_golang/issues/1183)
\[ENHANCEMENT] Add possibility to dynamically get label values for http
instrumentation
[#&#8203;1066](https://togithub.com/prometheus/client_golang/issues/1066)
\[ENHANCEMENT] Add ability to Pusher to add custom headers
[#&#8203;1218](https://togithub.com/prometheus/client_golang/issues/1218)
\[ENHANCEMENT] api: Extend and improve efficiency of json-iterator usage
[#&#8203;1225](https://togithub.com/prometheus/client_golang/issues/1225)
\[ENHANCEMENT] Added (official) support for go 1.20
[#&#8203;1234](https://togithub.com/prometheus/client_golang/issues/1234)
\[ENHANCEMENT] timer: Added support for exemplars
[#&#8203;1233](https://togithub.com/prometheus/client_golang/issues/1233)
\[ENHANCEMENT] Filter expected metrics as well in CollectAndCompare
[#&#8203;1143](https://togithub.com/prometheus/client_golang/issues/1143)
\[ENHANCEMENT] ⚠️ Only set start/end if time is not Zero. This breaks
compatibility in experimental api package. If you strictly depend on
empty time.Time as actual value, the behavior is now changed
[#&#8203;1238](https://togithub.com/prometheus/client_golang/issues/1238)

<details>
  <summary>All commits</summary>

- Merge release 1.14 to main by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1164
- Fix typo in doc comment by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1166
- Fix issue with atomic variables on ppc64le by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1171
- examples: Add exemplars and middleware examples by
[@&#8203;jessicalins](https://togithub.com/jessicalins) in
[prometheus/client_golang#1173
- Add context to "duplicate label names" to enable debugging by
[@&#8203;SpencerMalone](https://togithub.com/SpencerMalone) in
[prometheus/client_golang#1177
- Add constrained labels and Constrained variant for all MetricVecs by
[@&#8203;Okhoshi](https://togithub.com/Okhoshi) in
[prometheus/client_golang#1151
- Support for multiple samples within same metric by
[@&#8203;machadovilaca](https://togithub.com/machadovilaca) in
[prometheus/client_golang#1181
- Replace deprecated github.com/golang/protobuf package by
[@&#8203;zhsj](https://togithub.com/zhsj) in
[prometheus/client_golang#1183
- Bump golang.org/x/text to v0.3.8 to mitigate CVE-2022-32149 by
[@&#8203;b4bay](https://togithub.com/b4bay) in
[prometheus/client_golang#1187
- typo fix by
[@&#8203;ibreakthecloud](https://togithub.com/ibreakthecloud) in
[prometheus/client_golang#1178
- Add possibility to dynamically get label values for http
instrumentation by [@&#8203;Okhoshi](https://togithub.com/Okhoshi) in
[prometheus/client_golang#1066
- Bump github.com/cespare/xxhash/v2 from 2.1.2 to 2.2.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1199
- Bump github.com/prometheus/procfs from 0.8.0 to 0.9.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1198
- Bump golang.org/x/sys from 0.3.0 to 0.4.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1217
- Synchronize common files from prometheus/prometheus by
[@&#8203;prombot](https://togithub.com/prombot) in
[prometheus/client_golang#1213
- Bump github.com/prometheus/common from 0.37.0 to 0.39.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1197
- Add `Header` method to Pusher for custom header by
[@&#8203;songjiayang](https://togithub.com/songjiayang) in
[prometheus/client_golang#1218
- Synchronize common files from prometheus/prometheus by
[@&#8203;prombot](https://togithub.com/prombot) in
[prometheus/client_golang#1224
- api: Extend and improve json-iterator usage by
[@&#8203;beorn7](https://togithub.com/beorn7) in
[prometheus/client_golang#1225
- Indent example in godoc consistently by
[@&#8203;lamida](https://togithub.com/lamida) in
[prometheus/client_golang#1226
- Remove unnecessary check if label is nil in observeWithExemplar by
[@&#8203;dimonl](https://togithub.com/dimonl) in
[prometheus/client_golang#1235
- README: Remove not working gocoverage images. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1236
- Added support for go 1.20. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1234
- timer: Added support for exemplars. by
[@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1233
- Synchronize common files from prometheus/prometheus by
[@&#8203;prombot](https://togithub.com/prombot) in
[prometheus/client_golang#1237
- Filter expected metrics as well in CollectAndCompare by
[@&#8203;DariaKunoichi](https://togithub.com/DariaKunoichi) in
[prometheus/client_golang#1143
- Only set start/end if time is not Zero by
[@&#8203;jacksontj](https://togithub.com/jacksontj) in
[prometheus/client_golang#1238
- Bump google.golang.org/protobuf from 1.28.1 to 1.30.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1243
- Bump golang.org/x/sys from 0.5.0 to 0.6.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1246
- Bump github.com/golang/protobuf from 1.5.2 to 1.5.3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1245
- Bump github.com/prometheus/common from 0.41.0 to 0.42.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[prometheus/client_golang#1244
- Cut v1.15.0 by [@&#8203;bwplotka](https://togithub.com/bwplotka) in
[prometheus/client_golang#1249

</details>

#### New Contributors
* @&#8203;SpencerMalone made their first
contributi[prometheus/client_golang#1177
* @&#8203;Okhoshi made their first
contributi[prometheus/client_golang#1151
* @&#8203;machadovilaca made their first
contributi[prometheus/client_golang#1181
* @&#8203;b4bay made their first
contributi[prometheus/client_golang#1187
* @&#8203;ibreakthecloud made their first
contributi[prometheus/client_golang#1178
* @&#8203;songjiayang made their first
contributi[prometheus/client_golang#1218
* @&#8203;lamida made their first
contributi[prometheus/client_golang#1226
* @&#8203;dimonl made their first
contributi[prometheus/client_golang#1235
* @&#8203;DariaKunoichi made their first
contributi[prometheus/client_golang#1143

**Full Changelog**:
prometheus/client_golang@v1.14.0...v1.15.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:eyJjcmVhdGVkSW5WZXIiOiIzNS40MC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNDAuMCJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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

4 participants