Search in sources :

Example 16 with MockDispatcher

use of com.newrelic.agent.MockDispatcher 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());
}
Also used : JSONObject(org.json.simple.JSONObject) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) JSONArray(org.json.simple.JSONArray) MockDispatcher(com.newrelic.agent.MockDispatcher) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) MetricNameFormat(com.newrelic.agent.tracers.metricname.MetricNameFormat) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) Test(org.junit.Test)

Example 17 with MockDispatcher

use of com.newrelic.agent.MockDispatcher in project newrelic-java-agent by newrelic.

the class TransactionTraceBucketTest method createTransactionData.

private TransactionData createTransactionData(String transactionName, long durationInMillis) {
    AgentConfig agentConfig = ServiceFactory.getConfigService().getDefaultAgentConfig();
    MockDispatcher dispatcher = new MockDispatcher();
    dispatcher.setWebTransaction(true);
    MockDispatcherTracer rootTracer = new MockDispatcherTracer();
    rootTracer.setDurationInMilliseconds(durationInMillis);
    rootTracer.setStartTime(System.nanoTime());
    rootTracer.setEndTime(rootTracer.getStartTime() + TimeUnit.NANOSECONDS.convert(durationInMillis, TimeUnit.MILLISECONDS));
    return new TransactionDataTestBuilder(APP_NAME, agentConfig, rootTracer).setDispatcher(dispatcher).setRequestUri(transactionName).setFrontendMetricName(transactionName).build();
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) MockDispatcherTracer(com.newrelic.agent.MockDispatcherTracer) MockDispatcher(com.newrelic.agent.MockDispatcher) TransactionDataTestBuilder(com.newrelic.agent.TransactionDataTestBuilder)

Aggregations

MockDispatcher (com.newrelic.agent.MockDispatcher)17 MockDispatcherTracer (com.newrelic.agent.MockDispatcherTracer)11 TransactionDataTestBuilder (com.newrelic.agent.TransactionDataTestBuilder)10 AgentConfig (com.newrelic.agent.config.AgentConfig)9 Transaction (com.newrelic.agent.Transaction)8 Tracer (com.newrelic.agent.tracers.Tracer)7 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)6 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)6 TransactionData (com.newrelic.agent.TransactionData)5 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)5 Test (org.junit.Test)5 SqlTraceConfig (com.newrelic.agent.config.SqlTraceConfig)4 HashMap (java.util.HashMap)4 TransactionActivity (com.newrelic.agent.TransactionActivity)2 ServerProp (com.newrelic.agent.config.ServerProp)2 TransactionTracerConfig (com.newrelic.agent.config.TransactionTracerConfig)2 JSONObject (org.json.simple.JSONObject)2 ErrorCollectorConfig (com.newrelic.agent.config.ErrorCollectorConfig)1 NoOpTrackingSqlTracer (com.newrelic.agent.instrumentation.sql.NoOpTrackingSqlTracer)1 MethodExitTracer (com.newrelic.agent.tracers.MethodExitTracer)1