use of com.newrelic.agent.reinstrument.RemoteInstrumentationServiceImpl 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.reinstrument.RemoteInstrumentationServiceImpl 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.reinstrument.RemoteInstrumentationServiceImpl in project newrelic-java-agent by newrelic.
the class HighSecurityRemoteInstTest method runTest.
private ReinstrumentResult runTest(boolean highSecurity) {
RemoteInstrumentationServiceImpl impl = performSetupWork(highSecurity);
StringBuilder sb = new StringBuilder();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
sb.append("<extension xmlns=\"https://newrelic.com/docs/java/xsd/v1.0\"");
sb.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
sb.append(" xsi:schemaLocation=\"newrelic-extension extension.xsd \" name=\"testing 123\">");
sb.append("<instrumentation>");
sb.append("<pointcut transactionStartPoint=\"true\">");
sb.append("<className>com.newrelic.agent.reinstrument.InstrumentMeObj2");
sb.append("</className>");
sb.append("<method>");
sb.append("<name>getName</name>");
sb.append("<parameters>");
sb.append("<type>java.lang.String</type>");
sb.append("</parameters>");
sb.append("</method>");
sb.append("</pointcut>");
sb.append("</instrumentation>");
sb.append("</extension>");
return impl.processXml(sb.toString());
}
use of com.newrelic.agent.reinstrument.RemoteInstrumentationServiceImpl in project newrelic-java-agent by newrelic.
the class HighSecurityRemoteInstTest method performSetupWork.
private RemoteInstrumentationServiceImpl performSetupWork(boolean highSecurity) {
Map<String, Object> settings = new HashMap<>();
settings.put("app_name", APP_NAME);
if (highSecurity) {
settings.put(AgentConfigImpl.HIGH_SECURITY, Boolean.TRUE);
} else {
settings.put(AgentConfigImpl.HIGH_SECURITY, Boolean.FALSE);
}
manager.setConfigService(new ConfigServiceFactory().createConfigServiceUsingSettings(settings));
TransactionService transactionService = new TransactionService();
manager.setTransactionService(transactionService);
MockCoreService agent = new MockCoreService();
manager.setCoreService(agent);
agent.setInstrumentation(new InstrumentationProxy(new TestInstrumentation(), false));
// Needed by Transaction
TransactionTraceService transactionTraceService = new TransactionTraceService();
manager.setTransactionTraceService(transactionTraceService);
manager.setAttributesService(new AttributesService());
// Needed by Transaction
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
manager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
RemoteInstrumentationServiceImpl impl = new RemoteInstrumentationServiceImpl();
manager.setReinstrumentService(impl);
return impl;
}
Aggregations