Search in sources :

Example 16 with StatsService

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));
}
Also used : StatsService(com.newrelic.agent.stats.StatsService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 17 with StatsService

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));
}
Also used : StatsService(com.newrelic.agent.stats.StatsService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 18 with StatsService

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));
}
Also used : StatsService(com.newrelic.agent.stats.StatsService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 19 with StatsService

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()));
    }
}
Also used : StatsService(com.newrelic.agent.stats.StatsService)

Example 20 with StatsService

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()));
    }
}
Also used : StatsService(com.newrelic.agent.stats.StatsService)

Aggregations

StatsService (com.newrelic.agent.stats.StatsService)33 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)24 MockServiceManager (com.newrelic.agent.MockServiceManager)18 ConfigService (com.newrelic.agent.config.ConfigService)17 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)16 MockRPMService (com.newrelic.agent.MockRPMService)14 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)13 TransactionService (com.newrelic.agent.TransactionService)13 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)13 HarvestService (com.newrelic.agent.HarvestService)11 MockCoreService (com.newrelic.agent.MockCoreService)11 MockHarvestService (com.newrelic.agent.MockHarvestService)11 ThreadService (com.newrelic.agent.ThreadService)11 AgentConfig (com.newrelic.agent.config.AgentConfig)11 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)10 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)10 AttributesService (com.newrelic.agent.attributes.AttributesService)9 DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)8 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)7 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)7