Search in sources :

Example 1 with DistributedTraceServiceImpl

use of com.newrelic.agent.tracing.DistributedTraceServiceImpl in project newrelic-java-agent by newrelic.

the class SegmentTest method createServiceManager.

private static void createServiceManager(Map<String, Object> map, ExpirationService expirationService) throws Exception {
    ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(map);
    MockServiceManager serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    serviceManager.setConfigService(configService);
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    AsyncTransactionService asyncTxService = new AsyncTransactionService();
    serviceManager.setAsyncTransactionService(asyncTxService);
    TransactionService transactionService = new TransactionService(2, 1, 3, TimeUnit.SECONDS);
    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());
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    Map<String, Object> configMap = ImmutableMap.<String, Object>builder().put("cross_application_tracer", ImmutableMap.builder().put("account_id", "12abc345").put("trusted_account_key", "12abc345").build()).build();
    distributedTraceService.connected(null, AgentConfigFactory.createAgentConfig(configMap, null, null));
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    serviceManager.setExpirationService(expirationService);
    SpanEventsService spanEventsService = SpanEventsServiceFactory.builder().configService(configService).reservoirManager(new MockSpanEventReservoirManager(configService)).transactionService(serviceManager.getTransactionService()).rpmServiceManager(serviceManager.getRPMServiceManager()).spanEventCreationDecider(new SpanEventCreationDecider(configService)).environmentService(envService).transactionDataToDistributedTraceIntrinsics(transactionDataToDistributedTraceIntrinsics).build();
    serviceManager.setSpansEventService(spanEventsService);
    serviceManager.start();
}
Also used : StatsService(com.newrelic.agent.stats.StatsService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) SpanEventCreationDecider(com.newrelic.agent.service.analytics.SpanEventCreationDecider) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) SpanEventsService(com.newrelic.agent.service.analytics.SpanEventsService) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService)

Example 2 with DistributedTraceServiceImpl

use of com.newrelic.agent.tracing.DistributedTraceServiceImpl 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 3 with DistributedTraceServiceImpl

use of com.newrelic.agent.tracing.DistributedTraceServiceImpl in project newrelic-java-agent by newrelic.

the class TransactionAsyncUtility method createServiceManager.

public static void createServiceManager(Map<String, Object> map) throws Exception {
    ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(map);
    MockServiceManager serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    EnvironmentService envService = new EnvironmentServiceImpl();
    serviceManager.setEnvironmentService(envService);
    AsyncTransactionService asyncTxService = new AsyncTransactionService();
    serviceManager.setAsyncTransactionService(asyncTxService);
    serviceManager.setStatsService(new StatsServiceImpl());
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    serviceManager.setAttributesService(new AttributesService());
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    serviceManager.setExpirationService(new ExpirationService());
    serviceManager.start();
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) 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) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) 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) EnvironmentService(com.newrelic.agent.environment.EnvironmentService)

Example 4 with DistributedTraceServiceImpl

use of com.newrelic.agent.tracing.DistributedTraceServiceImpl in project newrelic-java-agent by newrelic.

the class TransactionEventsServiceTest method setup.

private void setup(boolean enabled, boolean isAttsEnabled, int size) throws Exception {
    MockServiceManager manager = new MockServiceManager();
    ServiceFactory.setServiceManager(manager);
    Map<String, Object> settings = new HashMap<>();
    settings.put("app_name", APP_NAME);
    Map<String, Object> events = new HashMap<>();
    settings.put("transaction_events", events);
    events.put("max_samples_stored", size);
    events.put("enabled", enabled);
    Map<String, Object> atts = new HashMap<>();
    settings.put("attributes", atts);
    atts.put("enabled", isAttsEnabled);
    Map<String, Object> distributedTracing = new HashMap<>();
    distributedTracing.put("enabled", true);
    settings.put("distributed_tracing", distributedTracing);
    Map<String, Object> spanConfig = new HashMap<>();
    spanConfig.put("collect_span_events", true);
    settings.put("span_events", spanConfig);
    iAgentConfig = AgentConfigImpl.createAgentConfig(settings);
    configService = ConfigServiceFactory.createConfigService(iAgentConfig, settings);
    manager.setConfigService(configService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    manager.setTransactionTraceService(transactionTraceService);
    environmentService = new EnvironmentServiceImpl();
    manager.setEnvironmentService(environmentService);
    AttributesService attService = new AttributesService();
    manager.setAttributesService(attService);
    TransactionService transactionService = new TransactionService();
    manager.setTransactionService(transactionService);
    StatsService statsService = new StatsServiceImpl();
    manager.setStatsService(statsService);
    HarvestService harvestService = new MockHarvestService();
    manager.setHarvestService(harvestService);
    // manager.setTransactionEventsService(new TransactionEventsService(mockDistributedTraceIntrinsics));
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    Map<String, Object> connectInfo = new HashMap<>();
    connectInfo.put(DistributedTracingConfig.ACCOUNT_ID, "1acct234");
    connectInfo.put(DistributedTracingConfig.TRUSTED_ACCOUNT_KEY, "67890");
    AgentConfig agentConfig = AgentHelper.createAgentConfig(true, Collections.<String, Object>emptyMap(), connectInfo);
    distributedTraceService.connected(null, agentConfig);
    manager.setDistributedTraceService(distributedTraceService);
    rpmServiceManager = new MockRPMServiceManager();
    rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmServiceManager.setRPMService(rpmService);
    ErrorServiceImpl errorService = new ErrorServiceImpl(APP_NAME);
    rpmService.setErrorService(errorService);
    rpmServiceAppName2 = (MockRPMService) rpmServiceManager.getOrCreateRPMService(APP_NAME_2);
    rpmServiceAppName2.setErrorService(new ErrorServiceImpl(APP_NAME_2));
    mockDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
    service = new TransactionEventsService(mockDistributedTraceIntrinsics);
    manager.setTransactionEventsService(service);
    manager.setRPMServiceManager(rpmServiceManager);
    service.addHarvestableToService(APP_NAME);
    service.doStart();
}
Also used : TransactionService(com.newrelic.agent.TransactionService) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) HashMap(java.util.HashMap) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) AgentConfig(com.newrelic.agent.config.AgentConfig) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMService(com.newrelic.agent.MockRPMService)

Example 5 with DistributedTraceServiceImpl

use of com.newrelic.agent.tracing.DistributedTraceServiceImpl in project newrelic-java-agent by newrelic.

the class SlowQueryInfoTest method testDTAttributes.

@Test
public void testDTAttributes() {
    Map<String, Object> settings = new HashMap<>();
    Map<String, Object> dtMap = new HashMap<>();
    dtMap.put("enabled", true);
    settings.put("distributed_tracing", dtMap);
    Map<String, Object> spanConfig = new HashMap<>();
    spanConfig.put("collect_span_events", true);
    settings.put("span_events", spanConfig);
    setupServiceManager(settings);
    DistributedTraceServiceImpl dts = (DistributedTraceServiceImpl) ServiceFactory.getServiceManager().getDistributedTraceService();
    Map<String, Object> configMap = ImmutableMap.<String, Object>builder().put("distributed_tracing", ImmutableMap.builder().put("primary_application_id", "1app23").put("trusted_account_key", "1tak23").put("account_id", "1acct234").build()).build();
    dts.connected(null, AgentConfigFactory.createAgentConfig(configMap, null, null));
    Transaction.clearTransaction();
    Transaction transaction = Transaction.getTransaction();
    transaction.getTransactionActivity().tracerStarted(new OtherRootTracer(transaction, new ClassMethodSignature("class", "method", "desc"), null, new SimpleMetricNameFormat("test")));
    String inboundPayload = "{\n" + "  \"v\": [\n" + "    0,\n" + "    2\n" + "  ],\n" + "  \"d\": {\n" + "    \"ty\": \"App\",\n" + "    \"ac\": \"1acct789\",\n" + "    \"ap\": \"1app23\",\n" + "    \"id\": \"27856f70d3d314b7\",\n" + "    \"tr\": \"3221bf09aa0bcf0d\",\n" + "    \"tk\": \"1tak23\",\n" + "    \"pr\": 1.0002,\n" + "    \"sa\": true,\n" + "    \"tx\": \"123456\",\n" + "    \"ti\": 1482959525577\n" + "  }\n" + "}";
    transaction.acceptDistributedTracePayload(inboundPayload);
    TransactionData data = new TransactionData(transaction, 100);
    Tracer tracer = new DefaultTracer(transaction, new ClassMethodSignature("ClassName", "methodName", "methodDesc"), null, null, TracerFlags.DISPATCHER);
    String obfuscatedQuery = "select ? from ?";
    HashMap<String, Object> sqlMap = new HashMap<>();
    ServerProp serverProp = ServerProp.createPropObject(SqlTraceConfigImpl.DEFAULT_USE_LONGER_SQL_ID);
    sqlMap.put(SqlTraceConfigImpl.USE_LONGER_SQL_ID, serverProp);
    SqlTraceConfig sqlTraceConfig = SqlTraceConfigImpl.createSqlTraceConfig(sqlMap);
    SlowQueryInfo slowQueryInfo = new SlowQueryInfo(data, tracer, "select * from person", obfuscatedQuery, sqlTraceConfig);
    assertNotNull(transaction.getSpanProxy().getInboundDistributedTracePayload());
    Map<String, Object> parameters = slowQueryInfo.getParameters();
    assertEquals("App", parameters.get("parent.type"));
    assertEquals("1app23", parameters.get("parent.app"));
    assertEquals("1acct789", parameters.get("parent.account"));
    assertNotNull(parameters.get("parent.transportType"));
    assertNotNull(parameters.get("parent.transportDuration"));
    assertNotNull(parameters.get("guid"));
    assertEquals("3221bf09aa0bcf0d", parameters.get("traceId"));
    assertNotNull(parameters.get("priority"));
    assertEquals(true, parameters.get("sampled"));
}
Also used : HashMap(java.util.HashMap) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) SqlTraceConfig(com.newrelic.agent.config.SqlTraceConfig) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) TransactionData(com.newrelic.agent.TransactionData) ServerProp(com.newrelic.agent.config.ServerProp) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) Test(org.junit.Test)

Aggregations

DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)21 AttributesService (com.newrelic.agent.attributes.AttributesService)16 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)15 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)13 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)12 TransactionEventsService (com.newrelic.agent.service.analytics.TransactionEventsService)12 ConfigService (com.newrelic.agent.config.ConfigService)11 TransactionDataToDistributedTraceIntrinsics (com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics)11 TransactionService (com.newrelic.agent.TransactionService)10 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)9 MockServiceManager (com.newrelic.agent.MockServiceManager)9 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)8 StatsService (com.newrelic.agent.stats.StatsService)8 HarvestService (com.newrelic.agent.HarvestService)7 ThreadService (com.newrelic.agent.ThreadService)7 AgentConfig (com.newrelic.agent.config.AgentConfig)7 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)7 MockCoreService (com.newrelic.agent.MockCoreService)6 MockHarvestService (com.newrelic.agent.MockHarvestService)6 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)6