use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class CollectorSpanEventReservoirManagerTest method retryOnHttpErrorWithNoDiscard.
@Test
public void retryOnHttpErrorWithNoDiscard() {
ConfigService mockConfigService = mock21Samples();
CollectorSpanEventReservoirManager target = initWith25Tries(mockConfigService);
ReservoirManager.HarvestResult harvestResult = target.attemptToSendReservoir(APP_NAME, (appName, reservoirSize, eventsSeen, events) -> {
throw new HttpError("don't discard", 429, 1234);
}, mock(Logger.class));
assertNull(harvestResult);
assertEquals(21, target.getOrCreateReservoir(APP_NAME).size());
assertEquals(21, target.getOrCreateReservoir(APP_NAME).getNumberOfTries());
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class CollectorSpanEventReservoirManagerTest method mock21Samples.
public ConfigService mock21Samples() {
ConfigService mockConfigService = Mockito.mock(ConfigService.class);
AgentConfig mockConfig = Mockito.mock(AgentConfig.class);
SpanEventsConfig mockSpanEventsConfig = Mockito.mock(SpanEventsConfig.class);
when(mockConfigService.getDefaultAgentConfig()).thenReturn(mockConfig);
when(mockConfigService.getAgentConfig(anyString())).thenReturn(mockConfig);
when(mockConfig.getSpanEventsConfig()).thenReturn(mockSpanEventsConfig);
when(mockSpanEventsConfig.getMaxSamplesStored()).thenReturn(21);
return mockConfigService;
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class CollectorSpanEventReservoirManagerTest method exceptionTriggerDiscard.
@Test
public void exceptionTriggerDiscard() {
ConfigService mockConfigService = mock21Samples();
CollectorSpanEventReservoirManager target = initWith25Tries(mockConfigService);
ReservoirManager.HarvestResult harvestResult = target.attemptToSendReservoir(APP_NAME, (appName, reservoirSize, eventsSeen, events) -> {
throw new RuntimeException("~~ oops ~~");
}, mock(Logger.class));
assertNull(harvestResult);
assertEquals(0, target.getOrCreateReservoir(APP_NAME).size());
assertEquals(0, target.getOrCreateReservoir(APP_NAME).getNumberOfTries());
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class CollectorSpanEventReservoirManagerTest method maxSamplesStoredConfiguredAfterConstruction.
@Test
public void maxSamplesStoredConfiguredAfterConstruction() {
ConfigService mockConfigService = mock21Samples();
CollectorSpanEventReservoirManager target = new CollectorSpanEventReservoirManager(mockConfigService);
assertEquals(21, target.getMaxSamplesStored());
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class EventTestHelper method createServiceManager.
public static void createServiceManager(Map<String, Object> config) throws Exception {
if (APP_NAME == null || APP_NAME.isEmpty()) {
APP_NAME = "Unit Test";
}
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), config);
serviceManager.setConfigService(configService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
TransactionService txService = new TransactionService();
serviceManager.setTransactionService(txService);
TransactionTraceService ttService = new TransactionTraceService();
serviceManager.setTransactionTraceService(ttService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmServiceManager.setRPMService(rpmService);
ErrorServiceImpl errorService = new ErrorServiceImpl(APP_NAME);
rpmService.setErrorService(errorService);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
serviceManager.setDistributedTraceService(new DistributedTraceServiceImpl());
serviceManager.setRPMServiceManager(rpmServiceManager);
}
Aggregations