Skip to content

Commit

Permalink
refactor(newrelic): get nr endpoint from config (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
derekmiller authored and maggieneterval committed Aug 30, 2019
1 parent 0c837a6 commit 8aa41e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
@Slf4j
public class NewRelicConfiguration {

private static final String NEWRELIC_INSIGHTS_ENDPOINT = "https://insights-api.newrelic.com";

@Bean
@ConfigurationProperties("kayenta.newrelic")
NewRelicConfigurationProperties newrelicConfigurationProperties() {
Expand Down Expand Up @@ -105,13 +103,17 @@ MetricsService newrelicMetricsService(
.applicationKey(account.getApplicationKey())
.build();

RemoteService remoteService = new RemoteService().setBaseUrl(NEWRELIC_INSIGHTS_ENDPOINT);
RemoteService endpoint = account.getEndpoint();

if (endpoint == null) {
endpoint = new RemoteService().setBaseUrl("https://insights-api.newrelic.com");
}

NewRelicNamedAccountCredentials.NewRelicNamedAccountCredentialsBuilder
accountCredentialsBuilder =
NewRelicNamedAccountCredentials.builder()
.name(name)
.endpoint(remoteService)
.endpoint(endpoint)
.credentials(credentials);

if (!CollectionUtils.isEmpty(supportedTypes)) {
Expand All @@ -120,7 +122,7 @@ MetricsService newrelicMetricsService(
retrofitClientFactory.createClient(
NewRelicRemoteService.class,
new JacksonConverter(objectMapper),
remoteService,
endpoint,
okHttpClient));
}
accountCredentialsBuilder.supportedTypes(supportedTypes);
Expand Down
1 change: 1 addition & 0 deletions kayenta-web/config/kayenta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ kayenta:
# defaultLocationKey: server_region # Optional, if omitted requests must supply the _location_key if it is needed.
# supportedTypes:
# - METRICS_STORE
# endpoint.baseUrl: https://insights-api.newrelic.com

prometheus:
enabled: false
Expand Down

0 comments on commit 8aa41e6

Please sign in to comment.