use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method createDispatcher.
private WebRequestDispatcher createDispatcher(Request httpRequest) throws Exception {
Transaction tx = Transaction.getTransaction();
Response httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
DefaultTracer tracer = new OtherRootTracer(tx, sig, this, new SimpleMetricNameFormat("test"));
tx.getTransactionActivity().tracerStarted(tracer);
WebRequestDispatcher dispatcher = new WebRequestDispatcher(httpRequest, httpResponse, tx);
tx.setDispatcher(dispatcher);
return dispatcher;
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class DistributedTraceServiceImplTest method configureAndCreatePayload.
private DistributedTracePayload configureAndCreatePayload(boolean excludeNewRelicHeader, boolean spanEventsEnabled) {
Map<String, Object> config = new HashMap<>();
config.put(AgentConfigImpl.APP_NAME, "Test");
Map<String, Object> dtConfig = new HashMap<>();
dtConfig.put(DistributedTracingConfig.ENABLED, true);
// This will need to change when we implement JAVA-5559
if (excludeNewRelicHeader) {
dtConfig.put(DistributedTracingConfig.EXCLUDE_NEWRELIC_HEADER, "true");
}
config.put(AgentConfigImpl.DISTRIBUTED_TRACING, dtConfig);
Map<String, Object> spansConfig = new HashMap<>();
spansConfig.put(SpanEventsConfig.ENABLED, spanEventsEnabled);
spansConfig.put(SpanEventsConfig.COLLECT_SPAN_EVENTS, true);
config.put(AgentConfigImpl.SPAN_EVENTS, spansConfig);
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(config);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
serviceManager.setConfigService(configService);
DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
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");
connectInfo.put(DistributedTracingConfig.EXCLUDE_NEWRELIC_HEADER, excludeNewRelicHeader);
AgentConfig connectData = AgentHelper.createAgentConfig(true, Collections.<String, Object>emptyMap(), connectInfo);
DistributedTraceServiceImplTest.distributedTraceService.connected(serviceManager.getRPMServiceManager().getRPMService(), connectData);
Transaction.clearTransaction();
txn = Transaction.getTransaction(true);
final ClassMethodSignature cms = new ClassMethodSignature("class", "method", "methodDesc");
final OtherRootTracer tracer = new OtherRootTracer(txn, cms, null, new SimpleMetricNameFormat("metricName"));
txn.getTransactionActivity().tracerStarted(tracer);
return distributedTraceService.createDistributedTracePayload(tracer);
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class BoundedConcurrentCacheTest method createSqlTracer.
public SqlTracer createSqlTracer(final long duration, RandomSql sql) {
SqlTracer defaultSqlTracer = new DefaultSqlTracer(tx, cms, new Object(), new SimpleMetricNameFormat("BoundedConcurrentCacheTest"), TracerFlags.GENERATE_SCOPED_METRIC) {
@Override
public long getDuration() {
return duration;
}
};
defaultSqlTracer.setRawSql(sql.getSql());
return defaultSqlTracer;
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class SqlTraceAggregatorTest method createTracer.
public SqlTracer createTracer(final String tableName, String sql, String host, int port, String dbName, long time, int duration) {
DefaultSqlTracer tracer = new OtherRootSqlTracer(Transaction.getTransaction(), new ClassMethodSignature("myclazz", "mymethod", "()V"), sql, new SimpleMetricNameFormat(null), DefaultTracer.DEFAULT_TRACER_FLAGS, time);
tracer.setRawSql("select * from " + tableName);
tracer.setHost(host);
tracer.setPort(port);
tracer.setDatabaseName(dbName);
Transaction.getTransaction().getTransactionActivity().tracerStarted(tracer);
tracer.performFinishWork(time + duration, Opcodes.ALOAD, null);
return tracer;
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class NormalizedTransactionTrace method testNormalizedTransactionTraceTest.
@SuppressWarnings({ "unchecked", "serial" })
@Test
public void testNormalizedTransactionTraceTest() {
final JSONArray rulesData = new JSONArray();
rulesData.addAll(Arrays.asList(new JSONObject() {
{
put("match_expression", "/amq.([0-9]*)$");
put("replacement", "/amq.*");
put("eval_order", 1);
}
}));
setUrlRules(rulesData);
Transaction txn = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("", "", "");
MetricNameFormat format = new SimpleMetricNameFormat("");
Tracer tracer = new OtherRootTracer(txn, sig, this, format);
txn.getTransactionActivity().tracerStarted(tracer);
MockDispatcher dispatcher = new MockDispatcher();
txn.setDispatcher(dispatcher);
txn.setTransactionName(TransactionNamePriority.FRAMEWORK_HIGH, false, "TEST", "/amq.1234567831415");
tracer.finish(Opcodes.ARETURN, null);
Assert.assertEquals("/amq.*", txn.getPriorityTransactionName().getPartialName());
}
Aggregations