Search in sources :

Example 21 with ExternalParameters

use of com.newrelic.api.agent.ExternalParameters in project newrelic-java-agent by newrelic.

the class MuleUtils method reportToAgent.

/**
 * Called inbound when using Http Transport. Verify this is consistent with usages of MuleHttpConnectorRequest in
 * the mule-3.6 and mule-3.7 modules.
 */
public static void reportToAgent(final MuleEvent muleEvent) {
    if (muleEvent == null) {
        NewRelic.getAgent().getLogger().log(Level.FINE, "MuleUtils#reportToAgent muleEvent is null");
        return;
    }
    MuleMessage message = muleEvent.getMessage();
    if (message == null) {
        NewRelic.getAgent().getLogger().log(Level.FINE, "MuleUtils#reportToAgent muleEvent.message is null");
        return;
    }
    final MuleHttpTransportRequest muleRequest = new MuleHttpTransportRequest(message);
    ExternalParameters params;
    try {
        URI uri = new URI(muleRequest.getRequestURI());
        params = HttpParameters.library("MuleHTTP").uri(uri).procedure("writeResponse").inboundHeaders(muleRequest).build();
    } catch (URISyntaxException uriSyntaxException) {
        params = HttpParameters.library("MuleHTTP").uri(UNKNOWN_HOST_URI).procedure("writeResponse").inboundHeaders(muleRequest).build();
    }
    NewRelic.getAgent().getTracedMethod().reportAsExternal(params);
    final Transaction txn = AgentBridge.getAgent().getTransaction(false);
    txn.setWebRequest(muleRequest);
    final String txnName = message.getInboundProperty("http.context.path") + " (" + muleRequest.getMethod() + ")";
    txn.setTransactionName(TransactionNamePriority.FRAMEWORK_HIGH, false, "Mule/Transport", txnName);
}
Also used : Transaction(com.newrelic.agent.bridge.Transaction) MuleMessage(org.mule.api.MuleMessage) ExternalParameters(com.newrelic.api.agent.ExternalParameters) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 22 with ExternalParameters

use of com.newrelic.api.agent.ExternalParameters in project newrelic-java-agent by newrelic.

the class DefaultTracerTest method testInstanceButNoPortSupportabilityMetrics.

@Test
public void testInstanceButNoPortSupportabilityMetrics() {
    DefaultTracer tracer = prepareTracer();
    String product = "Product";
    ExternalParameters parameters = DatastoreParameters.product(product).collection("Collection").operation("operation").instance("myHost", "instanceId").databaseName("databaseName").build();
    tracer.reportAsExternal(parameters);
    tracer.finish(0, null);
    checkUnknownDatastoreSupportabilityMetrics("Product", 0, 0, 0);
}
Also used : ExternalParameters(com.newrelic.api.agent.ExternalParameters) Test(org.junit.Test)

Example 23 with ExternalParameters

use of com.newrelic.api.agent.ExternalParameters in project newrelic-java-agent by newrelic.

the class DatastoreInstanceCrossAgentTests method runTest.

@Test
public void runTest() {
    // Setup system host
    DatastoreMetrics.setHostname(test.getSystemHostname());
    DefaultTracer tracer = createTracerInTransaction();
    ExternalParameters parameters = null;
    if (test.getPort() != null) {
        parameters = DatastoreParameters.product(test.getProduct()).collection(test.getProduct()).operation("operation").instance(test.getDbHostname(), test.getPort()).build();
    } else {
        parameters = DatastoreParameters.product(test.getProduct()).collection("collection").operation("operation").instance(test.getDbHostname(), test.getDbPath() != null ? test.getDbPath() : test.getUnixSocket()).databaseName("databaseName").slowQuery("raw query", null).build();
    }
    tracer.reportAsExternal(parameters);
    tracer.finish(Opcodes.ARETURN, null);
    Set<String> rollupMetricNames = tracer.getRollupMetricNames();
    assertTrue(MessageFormat.format("Could not find instance metric {0}", test.getExpectedInstanceMetric()), rollupMetricNames.contains(test.getExpectedInstanceMetric()));
}
Also used : ExternalParameters(com.newrelic.api.agent.ExternalParameters) Test(org.junit.Test)

Aggregations

ExternalParameters (com.newrelic.api.agent.ExternalParameters)23 Test (org.junit.Test)12 AgentConfig (com.newrelic.agent.config.AgentConfig)8 TokenNullCheckClassVisitor (com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPreprocessors.TokenNullCheckClassVisitor)8 DatastoreParameters (com.newrelic.api.agent.DatastoreParameters)8 SlowQueryDatastoreParameters (com.newrelic.api.agent.SlowQueryDatastoreParameters)8 SlowQueryWithInputDatastoreParameters (com.newrelic.api.agent.SlowQueryWithInputDatastoreParameters)8 HashMap (java.util.HashMap)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)8 ClassVisitor (org.objectweb.asm.ClassVisitor)8 ClassNode (org.objectweb.asm.tree.ClassNode)8 CheckClassAdapter (org.objectweb.asm.util.CheckClassAdapter)8 Trace (com.newrelic.api.agent.Trace)7 URISyntaxException (java.net.URISyntaxException)4 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)3 Tracer (com.newrelic.agent.tracers.Tracer)3 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)3 Segment (com.newrelic.api.agent.Segment)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2