use of com.newrelic.agent.stats.StatsService in project newrelic-java-agent by newrelic.
the class SamplerServiceImpl method mergeStatsEngine.
private void mergeStatsEngine(String appName) {
StatsService statsService = ServiceFactory.getStatsService();
StatsWork work = new MergeStatsEngine(appName, statsEngine);
statsService.doStatsWork(work, statsService.getName());
}
use of com.newrelic.agent.stats.StatsService in project newrelic-java-agent by newrelic.
the class RPMServiceTest method createServiceManager.
private void createServiceManager(AgentConfig config, Map<String, Object> localSettings) {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(config, localSettings);
serviceManager.setConfigService(configService);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
RPMConnectionService rpmConnectionService = new RPMConnectionServiceImpl();
serviceManager.setRPMConnectionService(rpmConnectionService);
ProfilerService profilerService = new ProfilerService();
serviceManager.setProfilerService(profilerService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
UtilizationService utilService = new UtilizationService();
serviceManager.setUtilizationService(utilService);
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
when(transactionDataToDistributedTraceIntrinsics.buildDistributedTracingIntrinsics(any(TransactionData.class), anyBoolean())).thenReturn(Collections.<String, Object>emptyMap());
TransactionEventsService transactionEventsService = new TransactionEventsService(transactionDataToDistributedTraceIntrinsics);
serviceManager.setTransactionEventsService(transactionEventsService);
serviceManager.setSpansEventService(mock(SpanEventsServiceImpl.class));
}
use of com.newrelic.agent.stats.StatsService 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();
}
use of com.newrelic.agent.stats.StatsService in project newrelic-java-agent by newrelic.
the class DefaultTracerTest method checkUnknownDatastoreSupportabilityMetrics.
private void checkUnknownDatastoreSupportabilityMetrics(String product, int expectedUnkownHost, int expectedUnknownPort, int expectedUnknownDatabaseName) {
StatsService statsService = ServiceFactory.getStatsService();
StatsEngine statsEngine = statsService.getStatsEngineForHarvest("Unit Test");
String unknownHostMetricName = new StringBuilder(MetricNames.SUPPORTABILITY_DATASTORE_PREFIX).append(product).append(MetricNames.SUPPORTABILITY_DATASTORE_UNKNOWN_HOST).toString();
Stats unknownHostMetric = statsEngine.getStats(unknownHostMetricName);
assertEquals(expectedUnkownHost, unknownHostMetric.getCallCount());
String unknownPortMetricName = new StringBuilder(MetricNames.SUPPORTABILITY_DATASTORE_PREFIX).append(product).append(MetricNames.SUPPORTABILITY_DATASTORE_UNKNOWN_PORT).toString();
Stats unknownPortMetric = statsEngine.getStats(unknownPortMetricName);
assertEquals(expectedUnknownPort, unknownPortMetric.getCallCount());
String unknownDatabaseMetricName = new StringBuilder(MetricNames.SUPPORTABILITY_DATASTORE_PREFIX).append(product).append(MetricNames.SUPPORTABILITY_DATASTORE_UNKNOWN_DATABASE_NAME).toString();
Stats unknownDatabaseNameMetric = statsEngine.getStats(unknownDatabaseMetricName);
assertEquals(expectedUnknownDatabaseName, unknownDatabaseNameMetric.getCallCount());
}
use of com.newrelic.agent.stats.StatsService 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();
}
Aggregations