use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class TransactionTest method createServiceManager.
private static void createServiceManager(Map<String, Object> map) throws Exception {
serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
serviceManager.setThreadService(threadService);
Map<String, Object> serverData = new HashMap<>();
serverData.put(CrossProcessConfigImpl.CROSS_PROCESS_ID, "12345#56789");
serverData.put(CrossProcessConfigImpl.APPLICATION_ID, "56789");
serverData.put(CrossProcessConfigImpl.TRUSTED_ACCOUNT_IDS, "12345,9123");
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, map, serverData);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
serviceManager.setConfigService(configService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
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());
serviceManager.setAsyncTransactionService(new AsyncTransactionService());
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
serviceManager.setDistributedTraceService(distributedTraceService);
distributedTraceService.start();
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
serviceManager.setExpirationService(new SegmentTest.InlineExpirationService());
AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
AgentBridge.agent = new AgentImpl(Agent.LOG);
List<ConnectionListener> connectionListeners = rpmServiceManager.getConnectionListeners();
for (ConnectionListener connectionListener : connectionListeners) {
connectionListener.connected(rpmServiceManager.getRPMService(), agentConfig);
}
}
use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class IntrospectorImpl method initialize.
private static IntrospectorServiceManager initialize(Map<String, Object> config) {
IntrospectorServiceManager manager = IntrospectorServiceManager.createAndInitialize(config);
try {
manager.start();
} catch (Exception e) {
// app will not work correctly
}
// initialize services / APIs
com.newrelic.api.agent.NewRelicApiImplementation.initialize();
com.newrelic.agent.PrivateApiImpl.initialize(Agent.LOG);
AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
return manager;
}
use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class WeaveTest method before.
@Before
public void before() {
test = new TestClass();
errorMessage = null;
throwable = null;
libraryName = null;
instrumentationThrowable = null;
AgentBridge.publicApi = new NewRelicApiImplementation() {
@Override
public void noticeError(String message) {
errorMessage = message;
}
@Override
public void noticeError(Throwable throwable) {
WeaveTest.this.throwable = throwable;
}
};
AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG) {
@Override
public void noticeInstrumentationError(Throwable throwable, String libraryName) {
WeaveTest.this.instrumentationThrowable = throwable;
WeaveTest.this.libraryName = libraryName;
}
};
}
use of com.newrelic.agent.instrumentation.InstrumentationImpl 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();
}
use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class CircuitBreakerServiceFunctionalTest method aTransaction.
@Trace(dispatcher = true)
private void aTransaction(boolean breakerTripped) {
Transaction transaction = NewRelic.getAgent().getTransaction();
InstrumentationImpl impl = new InstrumentationImpl(Agent.LOG);
if (breakerTripped) {
ExitTracer createdTracer = impl.createTracer(null, 0, "metricName", TracerFlags.DISPATCHER);
Assert.assertNull(createdTracer);
Assert.assertTrue(transaction instanceof NoOpTransaction);
} else {
Assert.assertTrue(transaction instanceof TransactionApiImpl);
}
}
Aggregations