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 completely new push syntax #381

Merged
merged 4 commits into from
Feb 14, 2018
Merged

Add completely new push syntax #381

merged 4 commits into from
Feb 14, 2018

Conversation

beorn7
Copy link
Member

@beorn7 beorn7 commented Feb 13, 2018

This allows adding more options in elegant ways, showcased here by
HTTP basic auth and by injecting a custom http.Client.

Fixes #341 and #372.

@grobie @alitari @shlimp

@beorn7
Copy link
Member Author

beorn7 commented Feb 13, 2018

See #341 in particular to see the idea behind this.

Copy link
Contributor

@brian-brazil brian-brazil left a comment

Choose a reason for hiding this comment

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

I think the general approach is fine, I'm not quite sure on the naming of the methods though.

@@ -67,18 +71,16 @@ func ExampleAddFromGatherer() {
if err != nil {
fmt.Println("DB backup failed:", err)
} else {
// Only now register successTime.
registry.MustRegister(successTime)
// Add succesTime to pusher only in case of success.
Copy link
Contributor

Choose a reason for hiding this comment

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

success

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

// We could as well register it with the registry.
// This example, however, demonstrates that you can
// mix Gatherers and Collectors when handling a Pusher.
pusher.Collector(successTime)
Copy link
Contributor

Choose a reason for hiding this comment

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

Its not clear to me at first glance exactly what this call is doing, is it pushing or is it registering?
AddCollector may be clearer

Copy link
Member Author

Choose a reason for hiding this comment

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

I had considered that name, too, but in the end I decided to go for the approach to use a verb only for the methods that are actually performing the push to the PGW (Push/Add) and use nouns for the methods that configure the push. This also makes the methods shorter. Furthermore, using the verb "add" specifically will easily get confused with the Add method.

Hence, I do thing the current naming is the clearest and easiest to handle. Does somebody else have an opinion on this?

return p
}

// HostnameGrouping adds a label pair with “instance” as the name and the
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason this existed was to allow for past mis-uses of the pgw when the pgw api changed quite some time ago. Now might be the time to remove it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Personally, I don't feel strongly. I vaguely remember that some people did feel strongly about it. @grobie @juliusv I think you were part of the debate.

If nobody speaks up now, I'll happily remove it.

Copy link
Member

Choose a reason for hiding this comment

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

I don't remember anything, but I'm for removing it. As the author of https://prometheus.io/docs/practices/pushing/, I really want to discourage this use :)

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, that's quorum. I have removed HostnameGrouping, adjusted the tests and examples, and edited the deprecation notice on the old HostnameGroupingKey.

beorn7 added 2 commits February 14, 2018 13:40
This allows adding more options in elegant ways, showcased here by
HTTP basic auth and by injecting a custom http.Client.

Fixes #341 and #372.
Copy link
Member

@grobie grobie 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 to me. I don't feel strongly about the naming, but I'd find AddCollector() and Add() more confusing, as I'd expect the first function to add the metrics for a single collector.

@beorn7 beorn7 merged commit 7e8a70d into master Feb 14, 2018
@beorn7 beorn7 deleted the beorn7/push branch February 14, 2018 18:20
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.

4 participants