Search in sources :

Example 1 with InstrumentationImpl

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);
    }
}
Also used : TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) SegmentTest(com.newrelic.agent.transaction.SegmentTest) SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService)

Example 2 with InstrumentationImpl

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;
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) IOException(java.io.IOException)

Example 3 with InstrumentationImpl

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

Example 4 with InstrumentationImpl

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();
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) HashMap(java.util.HashMap) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) CoreService(com.newrelic.agent.core.CoreService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) SpanEventCreationDecider(com.newrelic.agent.service.analytics.SpanEventCreationDecider) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) JSONObject(org.json.simple.JSONObject) Before(org.junit.Before)

Example 5 with InstrumentationImpl

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);
    }
}
Also used : ExitTracer(com.newrelic.agent.bridge.ExitTracer) NoOpTransaction(com.newrelic.agent.bridge.NoOpTransaction) Transaction(com.newrelic.api.agent.Transaction) InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) TransactionApiImpl(com.newrelic.agent.TransactionApiImpl) NoOpTransaction(com.newrelic.agent.bridge.NoOpTransaction) Trace(com.newrelic.api.agent.Trace)

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