mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Map connection and read timeouts for New Relic again
Closes gh-21440
This commit is contained in:
parent
53bf65df47
commit
069c31a074
@ -17,12 +17,14 @@
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.newrelic;
|
||||
|
||||
import io.micrometer.core.instrument.Clock;
|
||||
import io.micrometer.core.ipc.http.HttpUrlConnectionSender;
|
||||
import io.micrometer.newrelic.ClientProviderType;
|
||||
import io.micrometer.newrelic.NewRelicClientProvider;
|
||||
import io.micrometer.newrelic.NewRelicConfig;
|
||||
import io.micrometer.newrelic.NewRelicInsightsAgentClientProvider;
|
||||
import io.micrometer.newrelic.NewRelicInsightsApiClientProvider;
|
||||
import io.micrometer.newrelic.NewRelicMeterRegistry;
|
||||
import io.micrometer.newrelic.NewRelicMeterRegistry.Builder;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
|
||||
@ -67,13 +69,23 @@ public class NewRelicMetricsExportAutoConfiguration {
|
||||
return new NewRelicPropertiesConfigAdapter(this.properties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public NewRelicClientProvider newRelicClientProvider(NewRelicConfig newRelicConfig) {
|
||||
if (newRelicConfig.clientProviderType() == ClientProviderType.INSIGHTS_AGENT) {
|
||||
return new NewRelicInsightsAgentClientProvider(newRelicConfig);
|
||||
}
|
||||
return new NewRelicInsightsApiClientProvider(newRelicConfig,
|
||||
new HttpUrlConnectionSender(this.properties.getConnectTimeout(), this.properties.getReadTimeout()));
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public NewRelicMeterRegistry newRelicMeterRegistry(NewRelicConfig newRelicConfig, Clock clock,
|
||||
ObjectProvider<NewRelicClientProvider> newRelicClientProvider) {
|
||||
Builder builder = NewRelicMeterRegistry.builder(newRelicConfig).clock(clock);
|
||||
newRelicClientProvider.ifUnique(builder::clientProvider);
|
||||
return builder.build();
|
||||
NewRelicClientProvider newRelicClientProvider) {
|
||||
return NewRelicMeterRegistry.builder(newRelicConfig).clock(clock).clientProvider(newRelicClientProvider)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user