Skip to content

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Mar 4, 2019


private PushGateway getPushGateway(String url) {
try {
return new PushGateway(new URL(Objects.toString(url, "")));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to do Objects.toString(url, "") since the property has a default value of localhost:9091.

@wilkinsona wilkinsona changed the title Adds a way to set a custom Prometheus Gateway URL. Auto-configured PrometheusPushGatewayManager cannot be configured to use HTTPS to connect to the gateway Mar 6, 2019
@nosan
Copy link
Contributor Author

nosan commented Mar 6, 2019

@mbhave Thank you very much!
I have updated this PR.

@mbhave mbhave removed the status: waiting-for-triage An issue we've not yet triaged label Mar 8, 2019
Copy link
Member

@snicoll snicoll 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 the PR.

I am not sure that's quite what we had in mind. We want to get away from using the String based constructor as I am expecting prometheus to deprecate and remove it in a future release. We also want to educate our users and offer a migration strategy.

I am not sure how to deal with this: the property is called base-url but isn't an URL so we can't just change its type. If we keep a String there is no easy way to signal to users they have to provide a valid URL. IDEs do not perform any validation on the String at the moment so using a custom value hint won't help.

Push gateway calls the string-based one an address but I guess it's a bit dumb to rename it to re-introduce the URL-based afterwards.

Flagging for team attention to see what the rest of the team thinks.

Duration pushRate = properties.getPushRate();
String job = getJob(properties, environment);
Map<String, String> groupingKey = properties.getGroupingKey();
ShutdownOperation shutdownOperation = properties.getShutdownOperation();
return new PrometheusPushGatewayManager(pushGateway, collectorRegistry,
pushRate, job, groupingKey, shutdownOperation);
return new PrometheusPushGatewayManager(
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 see a reason to change the flow of the code here. I also feel that the previous version was easier to read. Can you please revert that part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

spring-java-format :(
I've introduced a variable to avoid this.

Copy link
Member

@snicoll snicoll Mar 19, 2019

Choose a reason for hiding this comment

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

That probably wasn't what I was talking about. I meant the fact you remove the PushGateway variable and therefore changed this constructor. I see no good reason for doing so.

Copy link
Contributor Author

@nosan nosan Mar 19, 2019

Choose a reason for hiding this comment

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

There are 2 constructors.

  • String creates URL as "http://" + address and delegates it to the underlying URL constructor.
  • URL uses URL as is.

So, that is why I've introduced a method to create a PushGateway instance using different constructors.

Copy link
Member

Choose a reason for hiding this comment

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

That's not what I am talking about and what you pushed force in the meantime is addressing it, thank you.

@snicoll snicoll added the for: team-attention An issue we'd like other members of the team to review label Mar 27, 2019
@philwebb philwebb modified the milestones: 2.1.x, 2.2.x Mar 27, 2019
@snicoll snicoll removed the for: team-attention An issue we'd like other members of the team to review label Mar 27, 2019
@snicoll
Copy link
Member

snicoll commented Mar 27, 2019

We've decided to try to parse the URL and log a warning if the URL is invalid, calling the deprecated constructor in that case. We'll also change the default value to include http:// in it. I'll do that as part of the polish.

@nosan
Copy link
Contributor Author

nosan commented Mar 27, 2019

@snicoll Thank you

@snicoll snicoll self-assigned this Mar 29, 2019
@snicoll snicoll modified the milestones: 2.2.x, 2.2.0.M2 Mar 29, 2019
@snicoll snicoll closed this in f4c4b1d Mar 29, 2019
snicoll added a commit that referenced this pull request Mar 29, 2019
* pr/16084:
  Polish "Permit use of https for configuring Prometheus push gateway"
  Permit use of https for configuring Prometheus push gateway
@nosan nosan deleted the gh-16073 branch March 29, 2019 17:13
izeye added a commit to izeye/micrometer that referenced this pull request Apr 16, 2019
shakuzen pushed a commit to micrometer-metrics/micrometer that referenced this pull request Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants