use of com.newrelic.agent.tracers.metricname.DefaultMetricNameFormat in project newrelic-java-agent by newrelic.
the class MetricNameFormatTest method defaultFormat.
@Test
public void defaultFormat() {
ClassMethodSignature sig = new ClassMethodSignature("com.foo.Bar", "getName()", "()V");
DefaultMetricNameFormat formatter = new DefaultMetricNameFormat(sig, this, "Java/{0}/{1}");
Assert.assertEquals("Java/com.newrelic.agent.tracers.nameformatters.MetricNameFormatTest/getName()", formatter.getMetricName());
Assert.assertEquals("Java/com.newrelic.agent.tracers.nameformatters.MetricNameFormatTest/getName()", formatter.getTransactionSegmentName());
formatter = new DefaultMetricNameFormat(sig, this, "Class/{0}");
Assert.assertEquals("Class/com.newrelic.agent.tracers.nameformatters.MetricNameFormatTest", formatter.getMetricName());
formatter = new DefaultMetricNameFormat(sig, this, "Method/{1}");
Assert.assertEquals("Method/getName()", formatter.getMetricName());
}
use of com.newrelic.agent.tracers.metricname.DefaultMetricNameFormat in project newrelic-java-agent by newrelic.
the class CrossProcessStateCatApiTest method trustAppAndGetTracer.
private CatTestCustomTracer trustAppAndGetTracer(String accountID) {
ImmutableMap<String, Object> crossProcessSettings = ImmutableMap.<String, Object>builder().put(CrossProcessConfigImpl.ENCODING_KEY, ENCODING_KEY).put(CrossProcessConfigImpl.ENABLED, Boolean.TRUE).put(CrossProcessConfigImpl.TRUSTED_ACCOUNT_IDS, accountID).put(CrossProcessConfigImpl.CROSS_PROCESS_ID, accountID + "#878").build();
// Disable DT for CAT specific tests
ImmutableMap<String, Object> distributedTracingSettings = ImmutableMap.<String, Object>builder().put(DistributedTracingConfig.ENABLED, Boolean.FALSE).build();
Map<String, Object> settings = new HashMap<>();
settings.put(AgentConfigImpl.CROSS_APPLICATION_TRACER, crossProcessSettings);
settings.put(AgentConfigImpl.APP_NAME, "TransactionAppNamingTest");
settings.put(AgentConfigImpl.DISTRIBUTED_TRACING, distributedTracingSettings);
ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(settings);
serviceManager.setConfigService(configService);
Transaction.clearTransaction();
Transaction transaction = Transaction.getTransaction(true);
ClassMethodSignature classMethodSignature = new ClassMethodSignature("className", "methodName", "methodDesc");
MetricNameFormat metricNameFormat = new DefaultMetricNameFormat(classMethodSignature, "", "something");
CatTestCustomTracer tracer = new CatTestCustomTracer(transaction, classMethodSignature, null, metricNameFormat, TracerFlags.DISPATCHER | TracerFlags.GENERATE_SCOPED_METRIC);
transaction.getTransactionActivity().tracerStarted(tracer);
cps = transaction.getCrossProcessState();
return tracer;
}
Aggregations