use of com.newrelic.agent.stats.StatsService in project newrelic-java-agent by newrelic.
the class DockerDataTest method testDockerError.
@Test
public void testDockerError() throws Exception {
MockCoreService.getMockAgentAndBootstrapTheServiceManager();
MockServiceManager mockServiceManager = new MockServiceManager();
StatsService spy = Mockito.spy(new StatsServiceImpl());
mockServiceManager.setStatsService(spy);
ServiceFactory.setServiceManager(mockServiceManager);
// Invalid docker id. Missing characters.
String invalidDockerId = "47cbd16b77c50cbf71401c069cd2189f0e659af17d5a2daca3bddf59d8a870";
StringReader reader = new StringReader("2:cpu:/docker/" + invalidDockerId);
Assert.assertNull(dockerData.readFile(reader));
}
use of com.newrelic.agent.stats.StatsService in project newrelic-java-agent by newrelic.
the class DockerDataTest method testDockerGCPError.
@Test
public void testDockerGCPError() throws Exception {
MockCoreService.getMockAgentAndBootstrapTheServiceManager();
MockServiceManager mockServiceManager = new MockServiceManager();
StatsService spy = Mockito.spy(new StatsServiceImpl());
mockServiceManager.setStatsService(spy);
ServiceFactory.setServiceManager(mockServiceManager);
// Invalid docker id. Missing characters.
String invalidDockerId = "47cbd16b77c50cbf71401c069cd2189f0e659af17d5a2daca3bddf59d8a870";
StringReader reader = new StringReader("2:cpu:/" + invalidDockerId);
Assert.assertNull(dockerData.readFile(reader));
}
use of com.newrelic.agent.stats.StatsService in project newrelic-java-agent by newrelic.
the class DockerDataTest method testNoDockerError.
@Test
public void testNoDockerError() throws Exception {
MockCoreService.getMockAgentAndBootstrapTheServiceManager();
MockServiceManager mockServiceManager = new MockServiceManager();
StatsService spy = Mockito.spy(new StatsServiceImpl());
mockServiceManager.setStatsService(spy);
ServiceFactory.setServiceManager(mockServiceManager);
String validDockerID = "47cbd16b77c50cbf71401c069cd2189f0e659af17d5a2daca3bddf59d8a870b2";
StringReader reader = new StringReader("2:cpu:/docker/" + validDockerID);
Assert.assertEquals(validDockerID, dockerData.readFile(reader));
}
use of com.newrelic.agent.stats.StatsService in project newrelic-java-agent by newrelic.
the class DistributedTraceServiceImpl method doStart.
@Override
protected void doStart() throws Exception {
ServiceFactory.getRPMServiceManager().addConnectionListener(this);
ServiceFactory.getTransactionService().addTransactionListener(this);
ServiceFactory.getHarvestService().addHarvestListener(this);
// track feature for angler
if (isEnabled()) {
StatsService statsService = ServiceFactory.getServiceManager().getStatsService();
statsService.getMetricAggregator().incrementCounter(MetricNames.SUPPORTABILITY_DISTRIBUTED_TRACING);
statsService.getMetricAggregator().incrementCounter(MessageFormat.format(MetricNames.SUPPORTABILITY_DISTRIBUTED_TRACING_EXCLUDE_NEWRELIC_HEADER, !distributedTraceConfig.isIncludeNewRelicHeader()));
}
}
use of com.newrelic.agent.stats.StatsService in project newrelic-java-agent by newrelic.
the class DistributedTraceServiceImpl method configChanged.
@Override
public void configChanged(String appName, AgentConfig agentConfig) {
boolean wasEnabled = isEnabled();
this.distributedTraceConfig = agentConfig.getDistributedTracingConfig();
if (!wasEnabled && isEnabled()) {
StatsService statsService = ServiceFactory.getServiceManager().getStatsService();
statsService.getMetricAggregator().incrementCounter(MetricNames.SUPPORTABILITY_DISTRIBUTED_TRACING);
statsService.getMetricAggregator().incrementCounter(MessageFormat.format(MetricNames.SUPPORTABILITY_DISTRIBUTED_TRACING_EXCLUDE_NEWRELIC_HEADER, !distributedTraceConfig.isIncludeNewRelicHeader()));
}
}
Aggregations