use of com.newrelic.agent.interfaces.backport.Consumer in project newrelic-java-agent by newrelic.
the class WeavePackageAnalyzerTest method weavePackageConstructionReadsAttributesFromJars.
@Test
public void weavePackageConstructionReadsAttributesFromJars() {
URL url = getClass().getResource('/' + ExtensionServiceTest.class.getPackage().getName().replace('.', '/') + '/' + ExtensionServiceTest.WEAVE_INSTRUMENTATION);
final List<JarData> jarData = new ArrayList<>();
Consumer<JarData> mockConsumer = new Consumer<JarData>() {
@Override
public void accept(JarData x) {
jarData.add(x);
}
};
WeavePackageAnalyzer target = new WeavePackageAnalyzer(new File(url.getFile()), mockConsumer, mock(Logger.class));
target.run();
assertEquals(1, jarData.size());
assertEquals("com.newrelic.instrumentation.spring-jms-2", jarData.get(0).getName());
assertEquals("1.0", jarData.get(0).getVersion());
assertEquals(url.toString(), jarData.get(0).getJarInfo().attributes.get("weaveFile"));
assertEquals("10ce178a632add8d5a98442a9cf1220f34c95874", jarData.get(0).getJarInfo().attributes.get("sha1Checksum"));
}
use of com.newrelic.agent.interfaces.backport.Consumer in project newrelic-java-agent by newrelic.
the class IntrospectorServiceManager method setup.
private void setup(Map<String, Object> config) {
configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), Collections.<String, Object>emptyMap());
ServiceFactory.setServiceManager(this);
coreService = new IntrospectorCoreService();
threadService = new ThreadService();
environmentService = new EnvironmentServiceImpl();
transactionService = new TransactionService();
rpmConnectionService = new IntrospectorRPMConnectService();
rpmServiceManager = new IntrospectorRPMServiceManager();
transactionTraceService = new IntrospectorTransactionTraceService();
asyncTxService = new AsyncTransactionService();
profilerService = new ProfilerService();
statsService = new IntrospectorStatsService();
harvestService = new IntrospectorHarvestService();
sqlTraceService = new SqlTraceServiceImpl();
insightsService = new IntrospectorInsightsService();
logSenderService = new IntrospectorLogSenderService();
expirationService = new ExpirationService();
dbService = new DatabaseService();
jarCollectorService = new IgnoringJarCollectorService();
distributedTraceService = new DistributedTraceServiceImpl();
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
transactionEventsService = new TransactionEventsService(transactionDataToDistributedTraceIntrinsics);
normalizationService = new NormalizationServiceImpl();
extensionService = new ExtensionService(configService, ExtensionsLoadedListener.NOOP);
tracerService = new TracerService();
commandParser = new CommandParser();
remoteInstrumentationService = new RemoteInstrumentationServiceImpl();
sourceLanguageService = new SourceLanguageService();
classTransformerService = new NoOpClassTransformerService();
jmxService = new JmxService(configService.getDefaultAgentConfig().getJmxConfig());
attributesService = new AttributesService();
circuitBreakerService = new CircuitBreakerService();
AgentConfig agentConfig = createAgentConfig(config, (Map) config.get("distributed_tracing"));
distributedTraceService.connected(null, agentConfig);
ReservoirManager<SpanEvent> reservoirManager = new CollectorSpanEventReservoirManager(configService);
ReservoirManager.EventSender<SpanEvent> collectorSender = new CollectorSpanEventSender(rpmServiceManager);
Consumer<SpanEvent> infiniteTracing = new Consumer<SpanEvent>() {
@Override
public void accept(SpanEvent spanEvent) {
}
};
SpanEventCreationDecider spanEventCreationDecider = new SpanEventCreationDecider(configService);
spanEventsService = new IntrospectorSpanEventService(agentConfig, reservoirManager, collectorSender, infiniteTracing, spanEventCreationDecider, environmentService, transactionDataToDistributedTraceIntrinsics);
configService.addIAgentConfigListener((IntrospectorSpanEventService) spanEventsService);
transactionService.addTransactionListener((IntrospectorSpanEventService) spanEventsService);
try {
transactionTraceService.start();
transactionEventsService.start();
transactionService.start();
} catch (Exception e) {
// fall through
}
}
use of com.newrelic.agent.interfaces.backport.Consumer in project newrelic-java-agent by newrelic.
the class SpanEventsServiceTest method before.
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
serviceManager = new MockServiceManager();
Map<String, Object> localSettings = new HashMap<>();
localSettings.put(AgentConfigImpl.APP_NAME, APP_NAME);
localSettings.put("distributed_tracing", Collections.singletonMap("enabled", true));
localSettings.put("span_events", Collections.singletonMap("collect_span_events", true));
when(spanEventCreationDecider.shouldCreateSpans(any(TransactionData.class))).thenReturn(true);
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, localSettings, new HashMap<String, Object>());
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, localSettings);
serviceManager.setConfigService(configService);
ServiceFactory.setServiceManager(serviceManager);
serviceManager.setTransactionService(new TransactionService());
serviceManager.setThreadService(new ThreadService());
final MockSpanEventReservoirManager reservoirManager = new MockSpanEventReservoirManager(configService);
Consumer<SpanEvent> backendConsumer = spanEvent -> reservoirManager.getOrCreateReservoir(APP_NAME).add(spanEvent);
SpanErrorBuilder defaultSpanErrorBuilder = new SpanErrorBuilder(new ErrorAnalyzerImpl(agentConfig.getErrorCollectorConfig()), new ErrorMessageReplacer(agentConfig.getStripExceptionConfig()));
Map<String, SpanErrorBuilder> map = new HashMap<>();
map.put(agentConfig.getApplicationName(), defaultSpanErrorBuilder);
EnvironmentService environmentService = mock(EnvironmentService.class, RETURNS_DEEP_STUBS);
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
when(transactionDataToDistributedTraceIntrinsics.buildDistributedTracingIntrinsics(any(TransactionData.class), anyBoolean())).thenReturn(Collections.<String, Object>emptyMap());
TracerToSpanEvent tracerToSpanEvent = new TracerToSpanEvent(map, environmentService, transactionDataToDistributedTraceIntrinsics, defaultSpanErrorBuilder);
SpanEventsServiceImpl spanEventsService = SpanEventsServiceImpl.builder().agentConfig(agentConfig).reservoirManager(reservoirManager).collectorSender(mock(CollectorSpanEventSender.class)).eventBackendStorage(backendConsumer).spanEventCreationDecider(spanEventCreationDecider).tracerToSpanEvent(tracerToSpanEvent).build();
serviceManager.setSpansEventService(spanEventsService);
serviceManager.setAttributesService(new AttributesService());
}
use of com.newrelic.agent.interfaces.backport.Consumer in project newrelic-java-agent by newrelic.
the class WeavePackageAnalyzerTest method usesWeavePackageConfigForAttributes.
@Test
public void usesWeavePackageConfigForAttributes() {
URL url = getClass().getResource('/' + ExtensionServiceTest.class.getPackage().getName().replace('.', '/') + '/' + ExtensionServiceTest.WEAVE_INSTRUMENTATION);
Consumer<JarData> mockConsumer = new Consumer<JarData>() {
@Override
public void accept(JarData x) {
}
};
WeavePackageAnalyzer target = new WeavePackageAnalyzer(new File(url.getFile()), mockConsumer, mock(Logger.class));
JarData jarData = target.getWeaveJar(new File(url.getFile()), WeavePackageConfig.builder().name("jms").version(6.66f).source(url.getPath()).build());
assertEquals("jms", jarData.getName());
assertEquals("6.66", jarData.getVersion());
assertEquals(url.getFile(), jarData.getJarInfo().attributes.get("weaveFile"));
assertEquals("10ce178a632add8d5a98442a9cf1220f34c95874", jarData.getJarInfo().attributes.get("sha1Checksum"));
}
Aggregations