use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class SlowQueryInfoTest method testDTAttributes.
@Test
public void testDTAttributes() {
Map<String, Object> settings = new HashMap<>();
Map<String, Object> dtMap = new HashMap<>();
dtMap.put("enabled", true);
settings.put("distributed_tracing", dtMap);
Map<String, Object> spanConfig = new HashMap<>();
spanConfig.put("collect_span_events", true);
settings.put("span_events", spanConfig);
setupServiceManager(settings);
DistributedTraceServiceImpl dts = (DistributedTraceServiceImpl) ServiceFactory.getServiceManager().getDistributedTraceService();
Map<String, Object> configMap = ImmutableMap.<String, Object>builder().put("distributed_tracing", ImmutableMap.builder().put("primary_application_id", "1app23").put("trusted_account_key", "1tak23").put("account_id", "1acct234").build()).build();
dts.connected(null, AgentConfigFactory.createAgentConfig(configMap, null, null));
Transaction.clearTransaction();
Transaction transaction = Transaction.getTransaction();
transaction.getTransactionActivity().tracerStarted(new OtherRootTracer(transaction, new ClassMethodSignature("class", "method", "desc"), null, new SimpleMetricNameFormat("test")));
String inboundPayload = "{\n" + " \"v\": [\n" + " 0,\n" + " 2\n" + " ],\n" + " \"d\": {\n" + " \"ty\": \"App\",\n" + " \"ac\": \"1acct789\",\n" + " \"ap\": \"1app23\",\n" + " \"id\": \"27856f70d3d314b7\",\n" + " \"tr\": \"3221bf09aa0bcf0d\",\n" + " \"tk\": \"1tak23\",\n" + " \"pr\": 1.0002,\n" + " \"sa\": true,\n" + " \"tx\": \"123456\",\n" + " \"ti\": 1482959525577\n" + " }\n" + "}";
transaction.acceptDistributedTracePayload(inboundPayload);
TransactionData data = new TransactionData(transaction, 100);
Tracer tracer = new DefaultTracer(transaction, new ClassMethodSignature("ClassName", "methodName", "methodDesc"), null, null, TracerFlags.DISPATCHER);
String obfuscatedQuery = "select ? from ?";
HashMap<String, Object> sqlMap = new HashMap<>();
ServerProp serverProp = ServerProp.createPropObject(SqlTraceConfigImpl.DEFAULT_USE_LONGER_SQL_ID);
sqlMap.put(SqlTraceConfigImpl.USE_LONGER_SQL_ID, serverProp);
SqlTraceConfig sqlTraceConfig = SqlTraceConfigImpl.createSqlTraceConfig(sqlMap);
SlowQueryInfo slowQueryInfo = new SlowQueryInfo(data, tracer, "select * from person", obfuscatedQuery, sqlTraceConfig);
assertNotNull(transaction.getSpanProxy().getInboundDistributedTracePayload());
Map<String, Object> parameters = slowQueryInfo.getParameters();
assertEquals("App", parameters.get("parent.type"));
assertEquals("1app23", parameters.get("parent.app"));
assertEquals("1acct789", parameters.get("parent.account"));
assertNotNull(parameters.get("parent.transportType"));
assertNotNull(parameters.get("parent.transportDuration"));
assertNotNull(parameters.get("guid"));
assertEquals("3221bf09aa0bcf0d", parameters.get("traceId"));
assertNotNull(parameters.get("priority"));
assertEquals(true, parameters.get("sampled"));
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class ExternalRequestImplTest method getTracer.
private DefaultTracer getTracer(String metricName, String transactionSegName) {
MetricNameFormat format = new SimpleMetricNameFormat(metricName, transactionSegName);
DefaultTracer tracer = new DefaultTracer(Transaction.getTransaction(), new ClassMethodSignature("class", "method", "()V"), new Object(), format);
return tracer;
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class ExternalsForTransactionTest method createTracer.
private DefaultTracer createTracer(String metricName, String txSegName) {
Transaction tx = Transaction.getTransaction();
SimpleMetricNameFormat format = new SimpleMetricNameFormat(metricName, txSegName);
DefaultTracer tracer = new DefaultTracer(tx, new ClassMethodSignature("myClass", "myMethod", "()V"), this, format);
return tracer;
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class IntrospectorImplTest method createOtherTracer.
public static OtherRootTracer createOtherTracer(String methodName) {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("MyClass", methodName, "()V");
OtherRootTracer brrt = new OtherRootTracer(tx, sig, new Object(), new SimpleMetricNameFormat(methodName));
return brrt;
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class ApiTest method testSetTransactionNameAfterGetBrowserInstrumentationFooter.
@Test
public void testSetTransactionNameAfterGetBrowserInstrumentationFooter() throws Exception {
ApiTestHelper.mockOutServiceManager();
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
NewRelic.setTransactionName("Test", "/foo1");
NewRelic.getBrowserTimingHeader();
// lock the name
NewRelic.getBrowserTimingFooter();
NewRelic.setTransactionName("Test", "/foo2");
// still foo1 as the name has been locked and the second setting of the name is ignored (and a message is logged)
Assert.assertEquals("OtherTransaction/Test/foo1", tx.getPriorityTransactionName().getName());
}
Aggregations