-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
api/prometheus/v1/api.go: Add support for status/runtimeinfo endpoint #755
Conversation
Signed-off-by: Lili Cosic <cosiclili@gmail.com>
Signed-off-by: Lili Cosic <cosiclili@gmail.com>
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
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.
Thanks. Looks good, just minor nits.
Also question about status code... not sure why we discard this!
@@ -238,6 +239,8 @@ type API interface { | |||
Query(ctx context.Context, query string, ts time.Time) (model.Value, Warnings, error) | |||
// QueryRange performs a query for the given range. | |||
QueryRange(ctx context.Context, query string, r Range) (model.Value, Warnings, error) | |||
// Runtimeinfo returns the various runtime information properties about the Prometheus server. |
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.
// Runtimeinfo returns the various runtime information properties about the Prometheus server. | |
// RuntimeInfo returns the various runtime information properties about the Prometheus server. |
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.
I disagree with this, as the endpoint is /runtimeinfo not /runtime_info, at least that was the logic I used here. :)
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.
Interesting, not a blocker, but this looks weird (:
@@ -238,6 +239,8 @@ type API interface { | |||
Query(ctx context.Context, query string, ts time.Time) (model.Value, Warnings, error) | |||
// QueryRange performs a query for the given range. | |||
QueryRange(ctx context.Context, query string, r Range) (model.Value, Warnings, error) | |||
// Runtimeinfo returns the various runtime information properties about the Prometheus server. | |||
Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) |
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.
Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) | |
RuntimeInfo(ctx context.Context) (RuntimeinfoResult, error) |
Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) | |
Runtimeinfo(ctx context.Context) (RuntimeInfoResult, error) |
@@ -277,6 +280,22 @@ type ConfigResult struct { | |||
// FlagsResult contains the result from querying the flag endpoint. | |||
type FlagsResult map[string]string | |||
|
|||
// RuntimeinfoResult contains the result from querying the runtimeinfo endpoint. | |||
type RuntimeinfoResult struct { |
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.
ditto
return RuntimeinfoResult{}, err | ||
} | ||
|
||
_, body, _, err := h.client.Do(ctx, req) |
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 looks like matches the other methods, but why we discard the status code completely? No point in marshaling if we don't check 2** status. 🤔
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.
Like you mentioned this just uses what the other functions use, but the custom .Do
does check for status :) https://github.com/prometheus/client_golang/blob/master/api/prometheus/v1/api.go#L880
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.
I think this is something to fix in follow up PRs if any, just it feels wrong, will add issue to follow up (:
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.
Agreed, we should fix it for all the functions! If you open issue can you ping me on it, thanks!
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.
Style seems aligned with all other functions.
lgtm 👍
Sorry for the waiting time, @lilic . I'm not really an expert of this HTTP client code. So I was just waiting for @bwplotka to signal if his nits have been addressed. And then I missed for how long nothing happened here. I now checked myself, and from my somewhat limited perspective, it looks fine to me. As @brancz seems happy, too, I'll merge this. Thank you very much! |
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,
Sorry @lilic you need to ping us, I totally forgot about it 🤗
@@ -238,6 +239,8 @@ type API interface { | |||
Query(ctx context.Context, query string, ts time.Time) (model.Value, Warnings, error) | |||
// QueryRange performs a query for the given range. | |||
QueryRange(ctx context.Context, query string, r Range) (model.Value, Warnings, error) | |||
// Runtimeinfo returns the various runtime information properties about the Prometheus server. |
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.
Interesting, not a blocker, but this looks weird (:
return RuntimeinfoResult{}, err | ||
} | ||
|
||
_, body, _, err := h.client.Do(ctx, req) |
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.
I think this is something to fix in follow up PRs if any, just it feels wrong, will add issue to follow up (:
Adds support for the status/runtimeinfo API endpoint as per the API docs https://prometheus.io/docs/prometheus/latest/querying/api/#runtime-information
Closes #746
cc @beorn7