Search in sources :

Example 1 with DefaultMetricNameFormat

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());
}
Also used : ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultMetricNameFormat(com.newrelic.agent.tracers.metricname.DefaultMetricNameFormat) Test(org.junit.Test)

Example 2 with DefaultMetricNameFormat

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;
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) HashMap(java.util.HashMap) DefaultMetricNameFormat(com.newrelic.agent.tracers.metricname.DefaultMetricNameFormat) Matchers.anyString(org.mockito.Matchers.anyString) DefaultMetricNameFormat(com.newrelic.agent.tracers.metricname.DefaultMetricNameFormat) ClassMethodMetricNameFormat(com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat) MetricNameFormat(com.newrelic.agent.tracers.metricname.MetricNameFormat)

Aggregations

ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)2 DefaultMetricNameFormat (com.newrelic.agent.tracers.metricname.DefaultMetricNameFormat)2 ConfigService (com.newrelic.agent.config.ConfigService)1 ClassMethodMetricNameFormat (com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat)1 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1