-
Notifications
You must be signed in to change notification settings - Fork 679
Switch prometheus/client_golang to a fork with support for /metrics endpoint filtering by name[]
#13746
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
Switch prometheus/client_golang to a fork with support for /metrics endpoint filtering by name[]
#13746
Conversation
/metrics endpoint filtering by name[]client_golang to a fork with support for /metrics endpoint filtering by name[]
client_golang to a fork with support for /metrics endpoint filtering by name[]prometheus/client_golang to a fork with support for /metrics endpoint filtering by name[]
|
|
||
| { | ||
| // One metric | ||
| res, err := http.Get(fmt.Sprintf("http://%s/metrics?name[]=go_info", c.Server.HTTPListenAddr())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Test doesn't wait for services to be ready
The test calls sm.StartAsync(t.Context()) but immediately makes HTTP requests to /metrics without waiting for services to become healthy or running. Other tests in this file either use m.AwaitHealthy(ctx) after StartAsync, or poll the /ready endpoint before making requests. This creates a race condition where the HTTP server may not be fully started when the first request is made, leading to intermittent test failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The listener is created before we call StartAsync, so there's no need to wait for it to be healthy, it will just serve the request once it's serving them.
duricanikolic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you
CHANGELOG.md
Outdated
| * [ENHANCEMENT] OTLP: Add metric `cortex_distributor_otlp_requests_by_content_type_total` to track content type (json or proto) of OTLP packets. #13525 | ||
| * [ENHANCEMENT] OTLP: Add experimental metric `cortex_distributor_otlp_array_lengths` to better understand the layout of OTLP packets in practice. #13525 | ||
| * [ENHANCEMENT] Ruler: gRPC errors without details are classified as `operator` errors, and rule evaluation failures (such as duplicate labelsets) are classified as `user` errors. #13586 | ||
| * [ENHANCEMENT] Server: The `/metrics` endpoint now supports metrics filtering by providing one or more `name[]` query parameters. #13745 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * [ENHANCEMENT] Server: The `/metrics` endpoint now supports metrics filtering by providing one or more `name[]` query parameters. #13745 | |
| * [ENHANCEMENT] Server: The `/metrics` endpoint now supports metrics filtering by providing one or more `name[]` query parameters. #13746 |
pkg/mimir/mimir_test.go
Outdated
| assert.Contains(t, string(body), "go_info") | ||
| assert.Contains(t, string(body), "deprecated_flags_inuse_total") | ||
| assert.NotContains(t, string(body), "go_gc_duration_seconds") | ||
| require.Equal(t, 1, strings.Count(string(body), "2")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this assertion on "2"? I can't understand it. Shouldn't assert on something like "HELP"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be definitely HELP, IDK where that 2 came from, probably I fell with my face on the keyboard and misedited it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, the "2" was supposed to go on the left, where the 1 was. It just happened that the output string had only one "2" so the test passed 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprising that the test passed anyway :D (and the desired value is also wrong, because it should be 2). Probably you replaced "HELP" with "2", instead of replacing "1" with "2".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me think it wasn't written by claude. AI doesn't make such mistakes :D
…tering by name[] Signed-off-by: Oleg Zaytsev <[email protected]>
73a948d to
56f3d09
Compare
Signed-off-by: Oleg Zaytsev <[email protected]>
Signed-off-by: Oleg Zaytsev <[email protected]>
What this PR does
Switches to a fork of
client_golangthat contains the PR prometheus/client_golang#1925 which supports/metricsendpoint handler filtering through the use ofname[]query param. I added a test to make sure this functionality doesn't disappear in a possible future removal of this replace directive.Also updates the costattribution package as this version now has changes introduced by @duricanikolic in prometheus/client_golang#1902
Which issue(s) this PR fixes or relates to
Fixes an internal issue
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]. If changelog entry is not needed, please add thechangelog-not-neededlabel to the PR.about-versioning.mdupdated with experimental features.Note
Switch to a forked
client_golangto add/metricsfiltering vianame[], update cost-attribution validation and tests, adapt API usage, and bumpcompress./metricsvianame[]query param (promhttp handler change). Added testTestMetricsEndpointSupportsMetricFiltering.github.com/prometheus/client_golangwith forkgithub.com/colega/prometheus-client_golang(pulls in filtering support) and vendor updates.github.com/klauspost/compresstov1.18.2and vendor changes.prometheus.Desc.Err(); adjust error expectations in tests.LabelNamesto newmodel.LabelNamesreturn type and convert to[]string./metricsfiltering enhancement.Written by Cursor Bugbot for commit 94aa553. This will update automatically on new commits. Configure here.