use of com.newrelic.agent.IRPMService in project newrelic-java-agent by newrelic.
the class TransactionTraceService method afterHarvest.
@Override
public void afterHarvest(String appName) {
List<TransactionTrace> traces = new ArrayList<>();
if (autoAppNameEnabled) {
traces.addAll(getNamedSamplerTraces(appName));
} else {
traces.addAll(getNamedSamplerTraces(TransactionTracerConfigImpl.REQUEST_CATEGORY_NAME));
traces.addAll(getNamedSamplerTraces(TransactionTracerConfigImpl.BACKGROUND_CATEGORY_NAME));
}
traces.addAll(this.syntheticsTransactionSampler.harvest(appName));
for (ITransactionSampler transactionSampler : transactionSamplers) {
traces.addAll(transactionSampler.harvest(appName));
}
if (!traces.isEmpty()) {
IRPMService rpmService = ServiceFactory.getRPMServiceManager().getOrCreateRPMService(appName);
sendTraces(rpmService, traces);
}
}
use of com.newrelic.agent.IRPMService in project newrelic-java-agent by newrelic.
the class DistributedTraceServiceImplTest method testConnectFields.
@Test
public void testConnectFields() {
assertNull(DistributedTraceServiceImplTest.distributedTraceService.getApplicationId());
assertNull(DistributedTraceServiceImplTest.distributedTraceService.getTrustKey());
assertNull(DistributedTraceServiceImplTest.distributedTraceService.getAccountId());
IRPMService rpmService = rpmServiceManager.getOrCreateRPMService("Test");
Map<String, Object> connectInfo = new HashMap<>();
connectInfo.put(DistributedTracingConfig.ACCOUNT_ID, "accountId");
connectInfo.put(DistributedTracingConfig.PRIMARY_APPLICATION_ID, "primaryApplicationId");
connectInfo.put(DistributedTracingConfig.TRUSTED_ACCOUNT_KEY, "trustKey");
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, Collections.<String, Object>emptyMap(), connectInfo);
DistributedTraceServiceImplTest.distributedTraceService.connected(rpmService, agentConfig);
assertEquals("accountId", DistributedTraceServiceImplTest.distributedTraceService.getAccountId());
assertEquals("primaryApplicationId", DistributedTraceServiceImplTest.distributedTraceService.getApplicationId());
assertEquals("trustKey", DistributedTraceServiceImplTest.distributedTraceService.getTrustKey());
}
use of com.newrelic.agent.IRPMService in project newrelic-java-agent by newrelic.
the class StartProfilerCommandTest method validArgs.
@Test
public void validArgs() throws CommandException {
IRPMService rpmService = null;
final long profileId = 1L;
final long duration = 60000L;
final long samplePeriod = 500L;
final boolean onlyRunnableThreads = true;
final boolean onlyRequestThreads = true;
final boolean profileAgentCode = true;
Map<String, Object> args = new HashMap<String, Object>() {
private static final long serialVersionUID = 1L;
{
put("profile_id", profileId);
put("sample_period", samplePeriod);
put("duration", duration);
put("only_runnable_threads", onlyRunnableThreads);
put("only_request_threads", onlyRequestThreads);
put("profile_agent_code", profileAgentCode);
}
};
startProfilerCommand.process(rpmService, args);
Assert.assertEquals(duration * 1000L, profilerParameters.getDurationInMillis().longValue());
Assert.assertEquals(samplePeriod * 1000L, profilerParameters.getSamplePeriodInMillis().longValue());
Assert.assertEquals(profileId, profilerParameters.getProfileId().longValue());
Assert.assertEquals(onlyRunnableThreads, profilerParameters.isRunnablesOnly());
Assert.assertEquals(onlyRequestThreads, profilerParameters.isOnlyRequestThreads());
Assert.assertEquals(profileAgentCode, profilerParameters.isProfileAgentThreads());
Assert.assertNull(profilerParameters.getKeyTransaction());
}
use of com.newrelic.agent.IRPMService in project newrelic-java-agent by newrelic.
the class StartProfilerCommandTest method noArguments.
@Test(expected = CommandException.class)
public void noArguments() throws CommandException {
IRPMService rpmService = null;
startProfilerCommand.process(rpmService, Collections.EMPTY_MAP);
}
use of com.newrelic.agent.IRPMService in project newrelic-java-agent by newrelic.
the class StartProfilerCommandTest method validArgsNullDefault.
@Test
public void validArgsNullDefault() throws CommandException {
IRPMService rpmService = null;
final long profileId = 1L;
final long duration = 60000L;
final long samplePeriod = 500L;
final boolean onlyRunnableThreads = true;
final boolean onlyRequestThreads = true;
final Object profileAgentCode = null;
Map<String, Object> args = new HashMap<String, Object>() {
private static final long serialVersionUID = 1L;
{
put("profile_id", profileId);
put("sample_period", samplePeriod);
put("duration", duration);
put("only_runnable_threads", onlyRunnableThreads);
put("only_request_threads", onlyRequestThreads);
put("profile_agent_code", profileAgentCode);
}
};
startProfilerCommand.process(rpmService, args);
Assert.assertEquals(duration * 1000L, profilerParameters.getDurationInMillis().longValue());
Assert.assertEquals(samplePeriod * 1000L, profilerParameters.getSamplePeriodInMillis().longValue());
Assert.assertEquals(profileId, profilerParameters.getProfileId().longValue());
Assert.assertEquals(onlyRunnableThreads, profilerParameters.isRunnablesOnly());
Assert.assertEquals(onlyRequestThreads, profilerParameters.isOnlyRequestThreads());
Assert.assertEquals(false, profilerParameters.isProfileAgentThreads());
Assert.assertNull(profilerParameters.getKeyTransaction());
}
Aggregations