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

Only log if superagent is enabled #2156

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Changes from all 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
@@ -7,6 +7,7 @@
package com.newrelic.agent.config;

import com.newrelic.agent.Agent;
import org.apache.commons.lang3.StringUtils;

import java.net.URI;
import java.net.URISyntaxException;
@@ -26,21 +27,22 @@ public class SuperAgentIntegrationConfigImpl extends BaseConfig implements Super
public SuperAgentIntegrationConfigImpl(Map<String, Object> configProps) {
super(configProps, SYSTEM_PROPERTY_ROOT);
superAgentIntegrationHealthConfig = createHealthConfig();
fleetId = superAgentIntegrationHealthConfig == null ? null : getProperty(FLEET_ID);
String tmpFleetId = getProperty(FLEET_ID);

if (StringUtils.isNotEmpty(tmpFleetId) && superAgentIntegrationHealthConfig.getHealthDeliveryLocation() == null) {
Agent.LOG.log(Level.WARNING, "Configured Super Agent health delivery location is not a valid URI; " +
"SuperAgent integration service will not be started");
fleetId = null;
} else {
fleetId = tmpFleetId;
}
}

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

superAgentIntegrationHealthConfig = new SuperAgentIntegrationHealthConfig(healthProps, SYSTEM_PROPERTY_ROOT);

if (superAgentIntegrationHealthConfig.getHealthDeliveryLocation() == null) {
Agent.LOG.log(Level.WARNING, "Configured Super Agent health delivery location is not a valid URI; " +
"SuperAgent integration service will not be started");
superAgentIntegrationHealthConfig = null;
}

return superAgentIntegrationHealthConfig;
}

Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@
import com.newrelic.api.agent.Logger;
import com.newrelic.api.agent.MetricAggregator;
import com.newrelic.api.agent.NewRelic;
import org.apache.commons.lang3.StringUtils;

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

private SuperAgentIntegrationService buildSuperAgentIntegrationService(AgentConfig config) {
SuperAgentIntegrationHealthClient healthClient =
SuperAgentIntegrationClientFactory.createHealthClient(config.getSuperAgentIntegrationConfig());

ArrayList<HealthDataProducer> healthDataProducers = new ArrayList<>();
healthDataProducers.add(circuitBreakerService);
healthDataProducers.add((HealthDataProducer) coreService);
for (IRPMService service : ServiceFactory.getRPMServiceManager().getRPMServices()) {
healthDataProducers.add(service.getHttpDataSenderAsHealthDataProducer());
SuperAgentIntegrationHealthClient healthClient = null;

if (config.getSuperAgentIntegrationConfig() != null && StringUtils.isNotEmpty(config.getSuperAgentIntegrationConfig().getFleetId())) {
healthClient = SuperAgentIntegrationClientFactory.createHealthClient(config.getSuperAgentIntegrationConfig());

healthDataProducers.add(circuitBreakerService);
healthDataProducers.add((HealthDataProducer) coreService);
for (IRPMService service : ServiceFactory.getRPMServiceManager().getRPMServices()) {
healthDataProducers.add(service.getHttpDataSenderAsHealthDataProducer());
}
}

return new SuperAgentIntegrationService(healthClient, config,
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ protected void doStop() throws Exception {

@Override
public boolean isEnabled() {
return agentConfig.getSuperAgentIntegrationConfig().isEnabled() && client.isValid();
return agentConfig.getSuperAgentIntegrationConfig().isEnabled() && client != null && client.isValid();
}

@Override