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

api/prometheus/v1/api.go: Add support for status/runtimeinfo endpoint #755

Merged
merged 2 commits into from Jun 3, 2020

Conversation

lilic
Copy link
Contributor

@lilic lilic commented May 18, 2020

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

lilic added 2 commits May 18, 2020 20:12
Signed-off-by: Lili Cosic <cosiclili@gmail.com>
Signed-off-by: Lili Cosic <cosiclili@gmail.com>
Copy link
Member

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

LGTM

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. 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Runtimeinfo returns the various runtime information properties about the Prometheus server.
// RuntimeInfo returns the various runtime information properties about the Prometheus server.

Copy link
Contributor Author

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. :)

Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error)
RuntimeInfo(ctx context.Context) (RuntimeinfoResult, error)
Suggested change
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 {
Copy link
Member

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)
Copy link
Member

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. 🤔

Copy link
Contributor Author

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

Copy link
Member

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 (:

Copy link
Contributor Author

@lilic lilic Jun 3, 2020

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!

Copy link
Member

@brancz brancz left a 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 👍

@lilic
Copy link
Contributor Author

lilic commented Jun 3, 2020

@beorn7 @bwplotka PTAL, thanks! :)

@beorn7
Copy link
Member

beorn7 commented Jun 3, 2020

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!

@beorn7 beorn7 merged commit 056e8af into prometheus:master Jun 3, 2020
@lilic lilic deleted the add-runtimeinfo branch June 3, 2020 11:46
@lilic
Copy link
Contributor Author

lilic commented Jun 3, 2020

@beorn7 no problem, thanks! if @bwplotka is not happy I can fix it in a follow up as well! :)

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,

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.
Copy link
Member

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)
Copy link
Member

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 (:

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.

Add support for /status/runtimeinfo endpoint to the api client
5 participants