Search in sources :

Example 6 with InstrumentationImpl

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();
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) Test(org.junit.Test)

Example 7 with InstrumentationImpl

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);
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) BeforeClass(org.junit.BeforeClass)

Example 8 with InstrumentationImpl

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);
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) AgentImpl(com.newrelic.agent.AgentImpl) BeforeClass(org.junit.BeforeClass)

Example 9 with InstrumentationImpl

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();
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) HashMap(java.util.HashMap) AttributesService(com.newrelic.agent.attributes.AttributesService) CoreService(com.newrelic.agent.core.CoreService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) JSONObject(org.json.simple.JSONObject) BeforeClass(org.junit.BeforeClass)

Example 10 with InstrumentationImpl

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);
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) CoreService(com.newrelic.agent.core.CoreService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) JSONObject(org.json.simple.JSONObject) Before(org.junit.Before)

Aggregations

InstrumentationImpl (com.newrelic.agent.instrumentation.InstrumentationImpl)10 AttributesService (com.newrelic.agent.attributes.AttributesService)4 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)4 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)4 CoreService (com.newrelic.agent.core.CoreService)3 TransactionDataToDistributedTraceIntrinsics (com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics)3 TransactionEventsService (com.newrelic.agent.service.analytics.TransactionEventsService)3 JSONObject (org.json.simple.JSONObject)3 Before (org.junit.Before)3 BeforeClass (org.junit.BeforeClass)3 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)2 DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)2 HashMap (java.util.HashMap)2 AgentImpl (com.newrelic.agent.AgentImpl)1 MockServiceManager (com.newrelic.agent.MockServiceManager)1 TransactionApiImpl (com.newrelic.agent.TransactionApiImpl)1 ExitTracer (com.newrelic.agent.bridge.ExitTracer)1 NoOpTransaction (com.newrelic.agent.bridge.NoOpTransaction)1 ConfigService (com.newrelic.agent.config.ConfigService)1 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)1