Search in sources :

Example 6 with EnvironmentService

use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.

the class CommandParserThreadProfilerTest method createServiceManager.

private MockServiceManager createServiceManager(Map<String, Object> config) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), config);
    serviceManager.setConfigService(configService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    RPMConnectionService rpmConnectionService = new RPMConnectionServiceImpl();
    serviceManager.setRPMConnectionService(rpmConnectionService);
    ProfilerService profilerService = new ProfilerService();
    serviceManager.setProfilerService(profilerService);
    EnvironmentService envService = new EnvironmentServiceImpl();
    serviceManager.setEnvironmentService(envService);
    HarvestService harvestService = new HarvestServiceImpl();
    serviceManager.setHarvestService(harvestService);
    return serviceManager;
}
Also used : ThreadService(com.newrelic.agent.ThreadService) ConfigService(com.newrelic.agent.config.ConfigService) TransactionService(com.newrelic.agent.TransactionService) RPMConnectionServiceImpl(com.newrelic.agent.rpm.RPMConnectionServiceImpl) HarvestService(com.newrelic.agent.HarvestService) RPMConnectionService(com.newrelic.agent.rpm.RPMConnectionService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) HarvestServiceImpl(com.newrelic.agent.HarvestServiceImpl) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) ProfilerService(com.newrelic.agent.profile.ProfilerService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService)

Example 7 with EnvironmentService

use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.

the class TracerToSpanEventTest method setup.

@Before
public void setup() {
    transactionAgentAttributes = new HashMap<>();
    transactionUserAttributes = new HashMap<>();
    tracerAgentAttributes = new HashMap<>();
    tracerUserAttributes = new HashMap<>();
    expectedAgentAttributes = new HashMap<>();
    expectedUserAttributes = new HashMap<>();
    expectedAgentAttributes.put("error.class", "0");
    expectedAgentAttributes.put("port", 9191);
    expectedIntrinsicAttributes = new HashMap<>();
    expectedIntrinsicAttributes.put("traceId", traceId);
    expectedIntrinsicAttributes.put("duration", (float) duration / TimeConversion.NANOSECONDS_PER_SECOND);
    expectedIntrinsicAttributes.put("type", "Span");
    expectedIntrinsicAttributes.put("category", "generic");
    expectedIntrinsicAttributes.put("sampled", sampled);
    expectedIntrinsicAttributes.put("nr.entryPoint", true);
    expectedIntrinsicAttributes.put("timestamp", timestamp);
    expectedIntrinsicAttributes.put("priority", priority);
    expectedIntrinsicAttributes.put("transaction.name", txnName.getName());
    tracer = mock(Tracer.class);
    txnData = mock(TransactionData.class);
    spanErrorBuilder = mock(SpanErrorBuilder.class);
    spanError = mock(SpanError.class);
    spanProxy = mock(SpanProxy.class);
    throwable = mock(TransactionThrowable.class);
    environmentService = mock(EnvironmentService.class);
    environment = mock(Environment.class);
    transactionDataToDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
    txnStats = mock(TransactionStats.class, RETURNS_DEEP_STUBS);
    errorBuilderMap = new HashMap<>();
    errorBuilderMap.put(appName, spanErrorBuilder);
    when(tracer.getDuration()).thenReturn(duration);
    when(tracer.getStartTimeInMillis()).thenReturn(timestamp);
    when(tracer.getAgentAttributes()).thenReturn(tracerAgentAttributes);
    when(tracer.getCustomAttributes()).thenReturn(tracerUserAttributes);
    when(spanErrorBuilder.buildSpanError(tracer, isRoot, responseStatus, statusMessage, throwable)).thenReturn(spanError);
    when(spanErrorBuilder.areErrorsEnabled()).thenReturn(true);
    when(txnData.getApplicationName()).thenReturn(appName);
    when(txnData.getResponseStatus()).thenReturn(responseStatus);
    when(txnData.getStatusMessage()).thenReturn(statusMessage);
    when(txnData.getThrowable()).thenReturn(throwable);
    when(txnData.getPriority()).thenReturn(priority);
    when(txnData.sampled()).thenReturn(sampled);
    when(txnData.getSpanProxy()).thenReturn(spanProxy);
    when(txnData.getPriorityTransactionName()).thenReturn(txnName);
    when(txnData.getUserAttributes()).thenReturn(transactionUserAttributes);
    when(spanProxy.getOrCreateTraceId()).thenReturn(traceId);
    when(environmentService.getEnvironment()).thenReturn(environment);
    when(environment.getAgentIdentity()).thenReturn(new AgentIdentity("dispatcher", "1.2.3", 9191, "myInstance"));
}
Also used : TransactionStats(com.newrelic.agent.stats.TransactionStats) Tracer(com.newrelic.agent.tracers.Tracer) SpanProxy(com.newrelic.agent.tracing.SpanProxy) TransactionThrowable(com.newrelic.agent.transaction.TransactionThrowable) SpanError(com.newrelic.agent.model.SpanError) Environment(com.newrelic.agent.environment.Environment) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) TransactionData(com.newrelic.agent.TransactionData) AgentIdentity(com.newrelic.agent.environment.AgentIdentity) Before(org.junit.Before)

Example 8 with EnvironmentService

use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.

the class CalculatePathHashTest method createServiceManager.

@Before
public void createServiceManager() throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    // Needed by TransactionService
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    // Needed by TransactionTraceService
    Map<String, Object> configMap = createConfigMap();
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
    serviceManager.setConfigService(configService);
    // Needed by Transaction
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    EnvironmentService envService = new EnvironmentServiceImpl();
    serviceManager.setEnvironmentService(envService);
    // Null pointers if not set
    serviceManager.setStatsService(Mockito.mock(StatsService.class));
    // Needed by Transaction
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    serviceManager.setAttributesService(new AttributesService());
    // Needed by Transaction
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
    rpmServiceManager.setRPMService(rpmService);
}
Also used : ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) AttributesService(com.newrelic.agent.attributes.AttributesService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) Before(org.junit.Before)

Example 9 with EnvironmentService

use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.

the class HarvestServiceTest method setup.

@Before
public void setup() throws Exception {
    AgentHelper.initializeConfig();
    ConfigService configService = ConfigServiceFactory.createConfigService(mock(Logger.class), false);
    MockServiceManager serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    Map<String, Object> settings = AgentConfigFactoryTest.createStagingMap();
    AgentConfig config = AgentConfigFactory.createAgentConfig(settings, null, null);
    Environment env = new Environment(config, "c:\\test\\log");
    EnvironmentService envService = Mockito.mock(EnvironmentService.class, new Returns(env));
    Mockito.doNothing().when(envService).stop();
    serviceManager.setEnvironmentService(envService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    statsService.start();
}
Also used : StatsService(com.newrelic.agent.stats.StatsService) Logger(com.newrelic.api.agent.Logger) AgentConfig(com.newrelic.agent.config.AgentConfig) Returns(org.mockito.internal.stubbing.answers.Returns) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) Environment(com.newrelic.agent.environment.Environment) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) Before(org.junit.Before)

Example 10 with EnvironmentService

use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.

the class SegmentTest method createServiceManager.

private static void createServiceManager(Map<String, Object> map, ExpirationService expirationService) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    AgentConfig agentConfig = AgentHelper.createAgentConfig(true, map, Collections.<String, Object>emptyMap());
    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);
    AsyncTransactionService asyncTxService = new AsyncTransactionService();
    serviceManager.setAsyncTransactionService(asyncTxService);
    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());
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    serviceManager.setExpirationService(expirationService);
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionService(com.newrelic.agent.TransactionService) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) ThreadService(com.newrelic.agent.ThreadService) AgentConfig(com.newrelic.agent.config.AgentConfig) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService)

Aggregations

EnvironmentService (com.newrelic.agent.environment.EnvironmentService)17 ConfigService (com.newrelic.agent.config.ConfigService)14 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)13 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)13 AttributesService (com.newrelic.agent.attributes.AttributesService)12 TransactionDataToDistributedTraceIntrinsics (com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics)9 TransactionEventsService (com.newrelic.agent.service.analytics.TransactionEventsService)9 StatsService (com.newrelic.agent.stats.StatsService)9 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)9 DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)8 MockServiceManager (com.newrelic.agent.MockServiceManager)7 ThreadService (com.newrelic.agent.ThreadService)7 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)7 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)7 HarvestService (com.newrelic.agent.HarvestService)6 TransactionService (com.newrelic.agent.TransactionService)6 AgentConfig (com.newrelic.agent.config.AgentConfig)5 Before (org.junit.Before)5 MockCoreService (com.newrelic.agent.MockCoreService)4 MockHarvestService (com.newrelic.agent.MockHarvestService)4