use of com.newrelic.agent.config.AgentConfigListener in project newrelic-java-agent by newrelic.
the class SpanEventsServiceFactoryTest method testBuildPicksStorageBackend_infiniteTracing.
@Test
public void testBuildPicksStorageBackend_infiniteTracing() throws Exception {
when(agentConfig.getApplicationName()).thenReturn(APP_NAME);
when(infiniteTracingConfig.isEnabled()).thenReturn(true);
when(spanEventsConfig.isEnabled()).thenReturn(true);
SpanEventsService service = SpanEventsServiceFactory.builder().configService(configService).rpmServiceManager(rpmServiceManager).infiniteTracingConsumer(infTracingConsumer).transactionService(transactionService).build();
service.storeEvent(event);
verify(infTracingConsumer).accept(event);
verify(reservoir, never()).add(event);
ArgumentCaptor<AgentConfigListener> configListener = ArgumentCaptor.forClass(AgentConfigListener.class);
ArgumentCaptor<TransactionListener> transactionListener = ArgumentCaptor.forClass(TransactionListener.class);
verify(configService, times(2)).addIAgentConfigListener(configListener.capture());
verify(transactionService).addTransactionListener(transactionListener.capture());
assertSame(configListener.getValue(), service);
assertSame(transactionListener.getValue(), service);
}
use of com.newrelic.agent.config.AgentConfigListener in project newrelic-java-agent by newrelic.
the class SpanEventsServiceFactoryTest method testBuildPicksStorageBackend_collector.
@Test
public void testBuildPicksStorageBackend_collector() throws Exception {
when(agentConfig.getApplicationName()).thenReturn(APP_NAME);
when(infiniteTracingConfig.isEnabled()).thenReturn(false);
when(spanEventsConfig.isEnabled()).thenReturn(true);
when(reservoirManager.getOrCreateReservoir(any())).thenReturn(reservoir);
SpanEventsService service = SpanEventsServiceFactory.builder().configService(configService).rpmServiceManager(rpmServiceManager).infiniteTracingConsumer(infTracingConsumer).transactionService(transactionService).reservoirManager(reservoirManager).build();
service.storeEvent(event);
verify(reservoir).add(event);
verify(infTracingConsumer, never()).accept(event);
ArgumentCaptor<AgentConfigListener> configListener = ArgumentCaptor.forClass(AgentConfigListener.class);
ArgumentCaptor<TransactionListener> transactionListener = ArgumentCaptor.forClass(TransactionListener.class);
verify(configService, times(2)).addIAgentConfigListener(configListener.capture());
verify(transactionService).addTransactionListener(transactionListener.capture());
assertSame(configListener.getValue(), service);
assertSame(transactionListener.getValue(), service);
}
use of com.newrelic.agent.config.AgentConfigListener in project newrelic-java-agent by newrelic.
the class DatabaseServiceTest method configChanged.
@Test
public void configChanged() throws Exception {
Map<String, Object> configMap = createStagingMap();
Map<String, Object> ttConfigMap = createMap();
ttConfigMap.put(TransactionTracerConfigImpl.COLLECT_TRACES, true);
configMap.put(AgentConfigImpl.TRANSACTION_TRACER, ttConfigMap);
MockServiceManager serviceManager = createServiceManager(configMap);
MockConfigService configService = new MockConfigService(null);
AgentConfig agentConfig = AgentConfigFactory.createAgentConfig(configMap, null, null);
configService.setAgentConfig(agentConfig);
serviceManager.setConfigService(configService);
DatabaseService dbService = ServiceFactory.getDatabaseService();
SqlObfuscator sqlObfuscator = dbService.getSqlObfuscator(APP_NAME);
Assert.assertTrue(sqlObfuscator.isObfuscating());
configMap = createStagingMap();
ttConfigMap = createMap();
configMap.put(AgentConfigImpl.TRANSACTION_TRACER, ttConfigMap);
ttConfigMap.put(TransactionTracerConfigImpl.RECORD_SQL, SqlObfuscator.OFF_SETTING);
agentConfig = AgentConfigFactory.createAgentConfig(configMap, null, null);
configService.setAgentConfig(agentConfig);
((AgentConfigListener) dbService).configChanged(APP_NAME, agentConfig);
sqlObfuscator = dbService.getSqlObfuscator(APP_NAME);
Assert.assertFalse(sqlObfuscator.isObfuscating());
Assert.assertNull(sqlObfuscator.obfuscateSql("select * from employees where id=737366255"));
}
Aggregations