Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
package io.micrometer.newrelic;

import java.time.Duration;

import io.micrometer.core.instrument.step.StepRegistryConfig;
import io.micrometer.core.ipc.http.HttpSender;

/**
* Configuration for {@link NewRelicMeterRegistry}.
Expand Down Expand Up @@ -86,5 +89,27 @@ default String uri() {
String v = get(prefix() + ".uri");
return (v == null) ? "https://insights-collector.newrelic.com" : v;
}

/**
* @return The connection timeout for {@link NewRelicInsightsApiClientProvider} requests to the Insights REST API.
* The default is 1 second.
* Connect timeout and read timeout have different meanings depending on the HTTP client. Configure
* timeout options on your {@link HttpSender} of choice instead.
*/
default Duration connectTimeout() {
String v = get(prefix() + ".connectTimeout");
return v == null ? Duration.ofSeconds(1) : Duration.parse(v);
}

/**
* @return The read timeout for {@link NewRelicInsightsApiClientProvider} requests to the Insights REST API.
* The default is 10 seconds.
* Connect timeout and read timeout have different meanings depending on the HTTP client. Configure
* timeout options on your {@link HttpSender} of choice instead.
*/
default Duration readTimeout() {
String v = get(prefix() + ".readTimeout");
return v == null ? Duration.ofSeconds(10) : Duration.parse(v);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ public class NewRelicInsightsApiClientProvider implements NewRelicClientProvider
NamingConvention namingConvention;
private final String insightsEndpoint;

@SuppressWarnings("deprecation")
public NewRelicInsightsApiClientProvider(NewRelicConfig config) {
this(config, new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()), new NewRelicNamingConvention());
}

@SuppressWarnings("deprecation")
public NewRelicInsightsApiClientProvider(NewRelicConfig config, String proxyHost, int proxyPort) {
this(config, new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout(),
new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort))), new NewRelicNamingConvention());
Expand Down