Search in sources :

Example 66 with SimpleMetricNameFormat

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;
}
Also used : Response(com.newrelic.api.agent.Response) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) WebRequestDispatcher(com.newrelic.agent.dispatchers.WebRequestDispatcher) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 67 with SimpleMetricNameFormat

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);
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) HashMap(java.util.HashMap) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 68 with SimpleMetricNameFormat

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;
}
Also used : DefaultSqlTracer(com.newrelic.agent.tracers.DefaultSqlTracer) SqlTracer(com.newrelic.agent.tracers.SqlTracer) DefaultSqlTracer(com.newrelic.agent.tracers.DefaultSqlTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 69 with SimpleMetricNameFormat

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;
}
Also used : SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Example 70 with SimpleMetricNameFormat

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());
}
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)

Aggregations

SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)70 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)46 Transaction (com.newrelic.agent.Transaction)43 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)34 Test (org.junit.Test)32 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)20 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)17 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)11 Response (com.newrelic.api.agent.Response)10 Tracer (com.newrelic.agent.tracers.Tracer)9 MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)9 ExtendedRequest (com.newrelic.api.agent.ExtendedRequest)8 Request (com.newrelic.api.agent.Request)8 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)8 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)8 MockHttpServletRequest (org.apache.struts.mock.MockHttpServletRequest)8 MockHttpServletResponse (org.apache.struts.mock.MockHttpServletResponse)8 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)7 TransactionDataList (com.newrelic.agent.TransactionDataList)6