use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class NoTransactionCreateTracerTest method testCreateTracerNoTx.
@Test
public void testCreateTracerNoTx() throws InterruptedException {
Runnable runnable = new Runnable() {
@Override
public void run() {
InstrumentationImpl ii = new InstrumentationImpl(new TestLogger());
// If there is an attempt to create a Transaction, it will throw because the config
// service doesn't exist. But this is caught and causes a null return, just like any
// other failure of any time. Must debug at that point to figure out what happened.
Assert.assertNotNull(ii.createTracer(new Object(), 1, null, TracerFlags.ASYNC));
Assert.assertNull(Transaction.getTransaction(false));
}
};
Thread thread = new Thread(runnable);
thread.start();
thread.join();
}
use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class SegmentTest method setup.
@BeforeClass
public static void setup() throws Exception {
inlineExpirationService = new InlineExpirationService();
createServiceManager(createConfigMap(), inlineExpirationService);
savedInstrumentation = AgentBridge.instrumentation;
savedAgent = AgentBridge.agent;
AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
AgentBridge.agent = new AgentImpl(Agent.LOG);
}
use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class CircuitBreakerServiceTest method setup.
@BeforeClass
public static void setup() {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
try {
serviceManager.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
AgentBridge.agent = new AgentImpl(Agent.LOG);
}
use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class DataCollectionConfigCrossAgentTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
savedInstrumentation = AgentBridge.instrumentation;
savedAgent = AgentBridge.agent;
serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
defaultConfig = new HashMap<>();
defaultConfig.put(AgentConfigImpl.APP_NAME, APP_NAME);
Map<String, Object> dtConfig = new HashMap<>();
dtConfig.put("enabled", true);
defaultConfig.put("distributed_tracing", dtConfig);
configService = setupConfig(defaultConfig);
serviceManager.setTransactionTraceService(new TransactionTraceService());
serviceManager.setTransactionService(new TransactionService());
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);
ServiceFactory.getServiceManager().start();
rpmService = (MockRPMService) rpmServiceManager.getRPMService();
}
use of com.newrelic.agent.instrumentation.InstrumentationImpl in project newrelic-java-agent by newrelic.
the class W3CTraceContextCrossAgentTest method setup.
@Before
public void setup() throws Exception {
savedInstrumentation = AgentBridge.instrumentation;
savedAgent = AgentBridge.agent;
serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
Map<String, Object> config = Maps.newHashMap();
config.put(AgentConfigImpl.APP_NAME, APP_NAME);
Map<String, Object> dtConfig = Maps.newHashMap();
dtConfig.put("enabled", true);
dtConfig.put("exclude_newrelic_header", true);
config.put("distributed_tracing", dtConfig);
Map<String, Object> spanConfig = Maps.newHashMap();
spanConfig.put("collect_span_events", true);
config.put("span_events", spanConfig);
ConfigService configService = setupConfig(config);
serviceManager.setTransactionTraceService(new TransactionTraceService());
serviceManager.setTransactionService(new TransactionService());
distributedTraceService = new DistributedTraceServiceImpl();
transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
serviceManager.setHarvestService(new HarvestServiceImpl());
statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
serviceManager.setEnvironmentService(new EnvironmentServiceImpl());
serviceManager.setAttributesService(new AttributesService());
AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
AgentBridge.agent = new AgentImpl(Agent.LOG);
CoreService coreService = Mockito.mock(CoreService.class);
when(coreService.isEnabled()).thenReturn(true);
serviceManager.setCoreService(coreService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
ServiceFactory.getServiceManager().start();
ServiceFactory.getTransactionService().addTransactionListener(distributedTraceService);
spanEventService = createSpanEventService(configService, transactionDataToDistributedTraceIntrinsics);
serviceManager.setDistributedTraceService(distributedTraceService);
serviceManager.setSpansEventService(spanEventService);
}
Aggregations