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

Map NewRelicProperties Connect and Read Timeouts To NewRelicConfig #21440

Conversation

neiljpowell
Copy link
Contributor

Add connect/readTimout property mapping so overridden values are propagated.

See related PR conversation: micrometer-metrics/micrometer#1961

@wilkinsona
Copy link
Member

Thanks for the PR. Reading through the Micrometer discussion and reminding myself of the reason for the property deprecation, I'm not sure that we should map them in Spring Boot. In addition to the use of deprecated API, it would make the NewRelic auto-configuration inconsistent with the various other auto-configurations where we configure an HttpSender with the timeouts:

@Bean
@ConditionalOnMissingBean
public DatadogMeterRegistry datadogMeterRegistry(DatadogConfig datadogConfig, Clock clock) {
return DatadogMeterRegistry.builder(datadogConfig).clock(clock).httpClient(
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()))
.build();
}

Ideally, we do something similar for NewRelic but the indirection of NewRelicClientProvider makes this harder. We could mimic the logic in NewRelicMeterRegistry and create the provider based on the config's clientProviderType and passing in an HttpSender but that's jumping through quite a few hoops.

I'm not sure what our best option is here and with 2.3.0.RELEASE due tomorrow, it's unlikely that we'll be able to figure this one out in time. Flagging for team attention nevertheless.

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label May 13, 2020
@neiljpowell
Copy link
Contributor Author

neiljpowell commented May 13, 2020

@wilkinsona Hi. Thanks for the quick response. @jkschneider proposed a fix in the auto configuration similar to example you provided in PR 1961 (above). I'm happy to update the PR as such, if you're comfortable with it.
CC: @shakuzen

jkschneider proposed fix:

@Bean
@ConditionalOnMissingBean
public NewRelicMeterRegistry newRelicMeterRegistry(NewRelicConfig newRelicConfig, 
  Clock clock, ObjectProvider<NewRelicClientProvider> newRelicClientProvider) {
	Builder builder = NewRelicMeterRegistry.builder(newRelicConfig).clock(clock);
	newRelicClientProvider.ifUnique(builder::clientProvider);

        // this is the fix, using the deprecated properties when no explicit client provider is given?
	if (!newRelicClientProvider.iterator().hasNext() && ClientProviderType.INSIGHTS_API.equals(newRelicConfig.clientProviderType())) {
		builder.clientProvider(new NewRelicInsightsApiClientProvider(newRelicConfig,
				new HttpUrlConnectionSender(newRelicConfig.connectTimeout(), newRelicConfig.readTimeout())));
	}
	return builder.build();
}

@snicoll
Copy link
Member

snicoll commented May 15, 2020

So, we can't do in that direction proposed by that PR. Micrometer has deprecated those methods and the plan is to remove them in Micrometer 2.0 so we shouldn't start using them.

After chatting with @shakuzen we essentially have two options:

  1. We replicate the logic to configure the NewRelicClientProvider based on the type. If the type is set to the Api provider, we configure the HttpSender with timeout values
  2. Micrometer offers an httpSender that we configure regardless of the provider as we do in other places. This would require a change in micrometer and we'd also require that exact version.

I'd like to experiment a bit on 1. and it feels to me it's the more reasonable option.

@neiljpowell
Copy link
Contributor Author

@snicoll Hi. I've updated the PR based on @jkschneider suggestion but using the NewRelicProperties connect/readTimeouts to avoid use of the deprecated config.

snicoll added a commit to snicoll/spring-boot that referenced this pull request May 26, 2020
@snicoll
Copy link
Member

snicoll commented May 26, 2020

Thanks @neiljpowell but I am not keen to pursue this suggestion. We should apply configuration on things that we auto-configure and leave user-configured bean untouched.

I've added something that looks relatively minimal in snicoll@3266cd2

@shakuzen what do you think?

@shakuzen
Copy link
Member

@snicoll Looks good to me. Thanks.

@neiljpowell
Copy link
Contributor Author

@snicoll Thank you for helping get the issue resolved. Interestingly, you landed on a simpler version of my original PR for adopting the changes. #20871. I will definitely keep that in mind.

@snicoll snicoll added type: bug A general bug and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels May 26, 2020
@snicoll snicoll modified the milestone: 2.3.1 May 26, 2020
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed type: bug A general bug labels May 26, 2020
@snicoll
Copy link
Member

snicoll commented May 26, 2020

Thanks for the feedback. I am going to decline this and will fix the issue on our side as part of #21578.

@snicoll snicoll closed this May 26, 2020
snicoll added a commit that referenced this pull request May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants