use of com.newrelic.agent.service.analytics.SpanEventCreationDecider in project newrelic-java-agent by newrelic.
the class SegmentTest method createServiceManager.
private static void createServiceManager(Map<String, Object> map, ExpirationService expirationService) throws Exception {
ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(map);
MockServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
serviceManager.setConfigService(configService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
AsyncTransactionService asyncTxService = new AsyncTransactionService();
serviceManager.setAsyncTransactionService(asyncTxService);
TransactionService transactionService = new TransactionService(2, 1, 3, TimeUnit.SECONDS);
serviceManager.setTransactionService(transactionService);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
serviceManager.setAttributesService(new AttributesService());
DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
Map<String, Object> configMap = ImmutableMap.<String, Object>builder().put("cross_application_tracer", ImmutableMap.builder().put("account_id", "12abc345").put("trusted_account_key", "12abc345").build()).build();
distributedTraceService.connected(null, AgentConfigFactory.createAgentConfig(configMap, null, null));
serviceManager.setDistributedTraceService(distributedTraceService);
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
serviceManager.setExpirationService(expirationService);
SpanEventsService spanEventsService = SpanEventsServiceFactory.builder().configService(configService).reservoirManager(new MockSpanEventReservoirManager(configService)).transactionService(serviceManager.getTransactionService()).rpmServiceManager(serviceManager.getRPMServiceManager()).spanEventCreationDecider(new SpanEventCreationDecider(configService)).environmentService(envService).transactionDataToDistributedTraceIntrinsics(transactionDataToDistributedTraceIntrinsics).build();
serviceManager.setSpansEventService(spanEventsService);
serviceManager.start();
}
use of com.newrelic.agent.service.analytics.SpanEventCreationDecider in project newrelic-java-agent by newrelic.
the class ServiceManagerImpl method doStart.
@Override
protected synchronized void doStart() throws Exception {
// The ConfigService has been created, but not started. This means it
// is safe to consult the config, but it will be the local config only.
coreService.start();
threadService = new ThreadService();
circuitBreakerService = new CircuitBreakerService();
classTransformerService = new ClassTransformerServiceImpl(coreService.getInstrumentation());
AgentConfig config = configService.getDefaultAgentConfig();
JmxConfig jmxConfig = config.getJmxConfig();
jmxService = new JmxService(jmxConfig);
Logger jarCollectorLogger = Agent.LOG.getChildLogger("com.newrelic.jar_collector");
boolean jarCollectorEnabled = configService.getDefaultAgentConfig().getJarCollectorConfig().isEnabled();
AtomicBoolean shouldSendAllJars = new AtomicBoolean(true);
TrackedAddSet<JarData> analyzedJars = new TrackedAddSet<>();
Function<URL, JarData> processor = new JarCollectorServiceProcessor(jarCollectorLogger, configService.getDefaultAgentConfig());
JarAnalystFactory jarAnalystFactory = new JarAnalystFactory(processor, analyzedJars, jarCollectorLogger);
ExecutorService executorService = Executors.newSingleThreadExecutor(new DefaultThreadFactory("New Relic Jar Analysis Thread", true));
JarCollectorInputs jarCollectorInputs = JarCollectorInputs.build(jarCollectorEnabled, jarAnalystFactory, executorService, jarCollectorLogger);
jarCollectorService = new JarCollectorServiceImpl(jarCollectorLogger, jarCollectorEnabled, shouldSendAllJars, analyzedJars, jarCollectorInputs.getClassNoticingFactory());
extensionService = new ExtensionService(configService, jarCollectorInputs.getExtensionAnalysisProducer());
String defaultAppName = configService.getDefaultAgentConfig().getApplicationName();
JarCollectorConnectionListener jarCollectorConnectionListener = new JarCollectorConnectionListener(defaultAppName, shouldSendAllJars);
JarCollectorHarvestListener jarCollectorHarvestListener = new JarCollectorHarvestListener(defaultAppName, jarCollectorService);
sourceLanguageService = new SourceLanguageService();
expirationService = new ExpirationService();
tracerService = new TracerService();
// this allows async parts of transaction to be registered
// it must be created before the first class transformation occurs
asyncTxService = new AsyncTransactionService();
// this is called in a transaction finish - it needs to be created before the first class transformation
environmentService = new EnvironmentServiceImpl();
/*
* Before this point the ClassTransformer is not initialized, so be careful not to load classes that should be
* instrumented.
*/
cacheService = new CacheService();
extensionService.start();
classTransformerService.start();
boolean realAgent = coreService.getInstrumentation() != null;
statsService = new StatsServiceImpl();
replayStartupStatsWork();
utilizationService = new UtilizationService();
// Start as early as possible.
if (realAgent) {
utilizationService.start();
}
rpmConnectionService = new RPMConnectionServiceImpl();
transactionService = new TransactionService();
InfiniteTracing infiniteTracing = buildInfiniteTracing(configService);
InfiniteTracingEnabledCheck infiniteTracingEnabledCheck = new InfiniteTracingEnabledCheck(configService);
SpanEventCreationDecider spanEventCreationDecider = new SpanEventCreationDecider(configService);
AgentConnectionEstablishedListener agentConnectionEstablishedListener = new UpdateInfiniteTracingAfterConnect(infiniteTracingEnabledCheck, infiniteTracing);
JfrConfig jfrConfig = config.getJfrConfig();
jfrService = new JfrService(jfrConfig, configService.getDefaultAgentConfig());
AgentConnectionEstablishedListener jfrServiceConnectionListener = new JfrServiceConnectionListener(jfrService);
distributedTraceService = new DistributedTraceServiceImpl();
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
rpmServiceManager = new RPMServiceManagerImpl(agentConnectionEstablishedListener, jarCollectorConnectionListener, jfrServiceConnectionListener);
normalizationService = new NormalizationServiceImpl();
harvestService = new HarvestServiceImpl();
gcService = realAgent ? new GCService() : new NoopService("GC Service");
transactionTraceService = new TransactionTraceService();
transactionEventsService = new TransactionEventsService(transactionDataToDistributedTraceIntrinsics);
profilerService = new ProfilerService();
commandParser = new CommandParser();
cpuSamplerService = realAgent ? new CPUSamplerService() : new NoopService("CPU Sampler");
deadlockDetectorService = new DeadlockDetectorService();
samplerService = realAgent ? new SamplerServiceImpl() : new NoopSamplerService();
sqlTraceService = new SqlTraceServiceImpl();
databaseService = new DatabaseService();
browserService = new BrowserServiceImpl();
remoteInstrumentationService = new RemoteInstrumentationServiceImpl();
attsService = new AttributesService();
insightsService = new InsightsServiceImpl();
logSenderService = new LogSenderServiceImpl();
spanEventsService = SpanEventsServiceFactory.builder().configService(configService).rpmServiceManager(rpmServiceManager).transactionService(transactionService).infiniteTracingConsumer(infiniteTracing).spanEventCreationDecider(spanEventCreationDecider).environmentService(environmentService).transactionDataToDistributedTraceIntrinsics(transactionDataToDistributedTraceIntrinsics).build();
// Register harvest listeners that started before harvest service was created.
harvestService.addHarvestListener(extensionService);
harvestService.addHarvestListener(jarCollectorHarvestListener);
asyncTxService.start();
threadService.start();
statsService.start();
environmentService.start();
rpmConnectionService.start();
tracerService.start();
jarCollectorService.start();
sourceLanguageService.start();
harvestService.start();
gcService.start();
transactionService.start();
transactionTraceService.start();
transactionEventsService.start();
profilerService.start();
commandParser.start();
jmxService.start();
cpuSamplerService.start();
deadlockDetectorService.start();
samplerService.start();
sqlTraceService.start();
browserService.start();
cacheService.start();
normalizationService.start();
databaseService.start();
configService.start();
remoteInstrumentationService.start();
attsService.start();
insightsService.start();
logSenderService.start();
circuitBreakerService.start();
distributedTraceService.start();
spanEventsService.start();
startServices();
// start last so other services can add connection listeners
rpmServiceManager.start();
// used for debugging purposes to quickly determine slow service startups
ServiceTiming.setEndTime();
ServiceTiming.logServiceTimings(getLogger());
}
use of com.newrelic.agent.service.analytics.SpanEventCreationDecider in project newrelic-java-agent by newrelic.
the class DistributedTraceCrossAgentTest method setUp.
@Before
public void setUp() throws Exception {
savedInstrumentation = AgentBridge.instrumentation;
savedAgent = AgentBridge.agent;
serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
Map<String, Object> config = new HashMap<>();
config.put(AgentConfigImpl.APP_NAME, APP_NAME);
Map<String, Object> dtConfig = new HashMap<>();
dtConfig.put("enabled", true);
config.put("distributed_tracing", dtConfig);
Map<String, Object> spanConfig = new HashMap<>();
spanConfig.put("collect_span_events", true);
config.put("span_events", spanConfig);
ConfigService configService = setupConfig(config);
distributedTraceService = new DistributedTraceServiceImpl();
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
serviceManager.setTransactionTraceService(new TransactionTraceService());
serviceManager.setTransactionService(new TransactionService());
serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
serviceManager.setHarvestService(new HarvestServiceImpl());
serviceManager.setStatsService(new StatsServiceImpl());
serviceManager.setEnvironmentService(new EnvironmentServiceImpl());
serviceManager.setAttributesService(new AttributesService());
AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
AgentBridge.agent = new AgentImpl(Agent.LOG);
serviceManager.setCoreService(mock(CoreService.class));
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
reservoirManager = new MockSpanEventReservoirManager(configService);
spanEventsService = SpanEventsServiceFactory.builder().configService(configService).reservoirManager(reservoirManager).transactionService(serviceManager.getTransactionService()).rpmServiceManager(serviceManager.getRPMServiceManager()).spanEventCreationDecider(new SpanEventCreationDecider(configService)).environmentService(ServiceFactory.getEnvironmentService()).transactionDataToDistributedTraceIntrinsics(transactionDataToDistributedTraceIntrinsics).build();
serviceManager.setDistributedTraceService(distributedTraceService);
serviceManager.setSpansEventService(spanEventsService);
ServiceFactory.getServiceManager().start();
}
Aggregations