Skip to content

Commit 6a2de60

Browse files
authored
Merge pull request #2156 from newrelic/sa-log-fix
Only log if superagent is enabled
2 parents 4431da3 + 0437e5d commit 6a2de60

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationConfigImpl.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package com.newrelic.agent.config;
88

99
import com.newrelic.agent.Agent;
10+
import org.apache.commons.lang3.StringUtils;
1011

1112
import java.net.URI;
1213
import java.net.URISyntaxException;
@@ -26,21 +27,22 @@ public class SuperAgentIntegrationConfigImpl extends BaseConfig implements Super
2627
public SuperAgentIntegrationConfigImpl(Map<String, Object> configProps) {
2728
super(configProps, SYSTEM_PROPERTY_ROOT);
2829
superAgentIntegrationHealthConfig = createHealthConfig();
29-
fleetId = superAgentIntegrationHealthConfig == null ? null : getProperty(FLEET_ID);
30+
String tmpFleetId = getProperty(FLEET_ID);
31+
32+
if (StringUtils.isNotEmpty(tmpFleetId) && superAgentIntegrationHealthConfig.getHealthDeliveryLocation() == null) {
33+
Agent.LOG.log(Level.WARNING, "Configured Super Agent health delivery location is not a valid URI; " +
34+
"SuperAgent integration service will not be started");
35+
fleetId = null;
36+
} else {
37+
fleetId = tmpFleetId;
38+
}
3039
}
3140

3241
private SuperAgentIntegrationHealthConfig createHealthConfig() {
3342
Map<String, Object> healthProps = getProperty(SuperAgentIntegrationHealthConfig.ROOT, Collections.emptyMap());
3443
SuperAgentIntegrationHealthConfig superAgentIntegrationHealthConfig;
3544

3645
superAgentIntegrationHealthConfig = new SuperAgentIntegrationHealthConfig(healthProps, SYSTEM_PROPERTY_ROOT);
37-
38-
if (superAgentIntegrationHealthConfig.getHealthDeliveryLocation() == null) {
39-
Agent.LOG.log(Level.WARNING, "Configured Super Agent health delivery location is not a valid URI; " +
40-
"SuperAgent integration service will not be started");
41-
superAgentIntegrationHealthConfig = null;
42-
}
43-
4446
return superAgentIntegrationHealthConfig;
4547
}
4648

newrelic-agent/src/main/java/com/newrelic/agent/service/ServiceManagerImpl.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import com.newrelic.api.agent.Logger;
9292
import com.newrelic.api.agent.MetricAggregator;
9393
import com.newrelic.api.agent.NewRelic;
94+
import org.apache.commons.lang3.StringUtils;
9495

9596
import java.net.URL;
9697
import java.util.ArrayList;
@@ -355,14 +356,17 @@ private InfiniteTracing buildInfiniteTracing(ConfigService configService) {
355356
}
356357

357358
private SuperAgentIntegrationService buildSuperAgentIntegrationService(AgentConfig config) {
358-
SuperAgentIntegrationHealthClient healthClient =
359-
SuperAgentIntegrationClientFactory.createHealthClient(config.getSuperAgentIntegrationConfig());
360-
361359
ArrayList<HealthDataProducer> healthDataProducers = new ArrayList<>();
362-
healthDataProducers.add(circuitBreakerService);
363-
healthDataProducers.add((HealthDataProducer) coreService);
364-
for (IRPMService service : ServiceFactory.getRPMServiceManager().getRPMServices()) {
365-
healthDataProducers.add(service.getHttpDataSenderAsHealthDataProducer());
360+
SuperAgentIntegrationHealthClient healthClient = null;
361+
362+
if (config.getSuperAgentIntegrationConfig() != null && StringUtils.isNotEmpty(config.getSuperAgentIntegrationConfig().getFleetId())) {
363+
healthClient = SuperAgentIntegrationClientFactory.createHealthClient(config.getSuperAgentIntegrationConfig());
364+
365+
healthDataProducers.add(circuitBreakerService);
366+
healthDataProducers.add((HealthDataProducer) coreService);
367+
for (IRPMService service : ServiceFactory.getRPMServiceManager().getRPMServices()) {
368+
healthDataProducers.add(service.getHttpDataSenderAsHealthDataProducer());
369+
}
366370
}
367371

368372
return new SuperAgentIntegrationService(healthClient, config,

newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected void doStop() throws Exception {
6565

6666
@Override
6767
public boolean isEnabled() {
68-
return agentConfig.getSuperAgentIntegrationConfig().isEnabled() && client.isValid();
68+
return agentConfig.getSuperAgentIntegrationConfig().isEnabled() && client != null && client.isValid();
6969
}
7070

7171
@Override

0 commit comments

Comments
 (0)