use of com.newrelic.agent.bridge.TracedMethod in project newrelic-java-agent by newrelic.
the class HttpMethodBase method releaseConnection.
@Trace(leaf = true)
public void releaseConnection() {
TracedMethod method = AgentBridge.getAgent().getTracedMethod();
if (!checkForIgnoredSocketCall(method)) {
try {
String host = getHostname();
URI methodURI = getURI();
String uri = URISupport.getURI(methodURI.getScheme(), methodURI.getHost(), methodURI.getPort(), methodURI.getPath());
// This method doesn't have any network I/O so we are explicitly not recording external rollup metrics
ExternalMetrics.makeExternalComponentMetric(method, host, LIBRARY, false, uri, "releaseConnection");
} catch (Throwable e) {
AgentBridge.getAgent().getLogger().log(Level.FINER, e, "Unable to record external metrics for releaseConnection()");
}
}
Weaver.callOriginal();
}
use of com.newrelic.agent.bridge.TracedMethod in project newrelic-java-agent by newrelic.
the class HttpMethodBase method getResponseBody.
@Trace(leaf = true)
public byte[] getResponseBody(int maxlen) throws IOException {
TracedMethod method = AgentBridge.getAgent().getTracedMethod();
if (!checkForIgnoredSocketCall(method)) {
try {
String host = getHostname();
URI methodURI = getURI();
String uri = URISupport.getURI(methodURI.getScheme(), methodURI.getHost(), methodURI.getPort(), methodURI.getPath());
// This method doesn't have any network I/O so we are explicitly not recording external rollup metrics
ExternalMetrics.makeExternalComponentMetric(method, host, LIBRARY, false, uri, "getResponseBody");
} catch (Throwable e) {
AgentBridge.getAgent().getLogger().log(Level.FINER, e, "Unable to record external metrics for getResponseBody()");
}
}
return Weaver.callOriginal();
}
use of com.newrelic.agent.bridge.TracedMethod in project newrelic-java-agent by newrelic.
the class ExternalMetricsTest method testNullHost.
@Test
public void testNullHost() throws Exception {
TracedMethod tracedMethod = Mockito.mock(TracedMethod.class);
Transaction transaction = Mockito.mock(Transaction.class);
String nullHost = null;
ExternalMetrics.makeExternalComponentTrace(transaction, tracedMethod, nullHost, "library", true, "http://uri", "operation");
}
use of com.newrelic.agent.bridge.TracedMethod in project newrelic-java-agent by newrelic.
the class SnsClient_Instrumentation method publish.
@Trace
public PublishResponse publish(PublishRequest publishRequest) throws InvalidParameterException, InvalidParameterValueException, InternalErrorException, NotFoundException, EndpointDisabledException, PlatformApplicationDisabledException, AuthorizationErrorException, KmsDisabledException, KmsInvalidStateException, KmsNotFoundException, KmsOptInRequiredException, KmsThrottlingException, KmsAccessDeniedException, InvalidSecurityException, AwsServiceException, SdkClientException, SnsException {
TracedMethod tracedMethod = AgentBridge.getAgent().getTracedMethod();
ExternalParameters params = SnsClientInstrumentationHelper.makeMessageProducerParameters(publishRequest);
tracedMethod.reportAsExternal(params);
return Weaver.callOriginal();
}
use of com.newrelic.agent.bridge.TracedMethod in project newrelic-java-agent by newrelic.
the class SegmentTest method testAsyncNamedTracedActivity.
/**
* tracer(dispatcher) start
* --tracedActivity start
* --tracedActivity finish (On a different thread)
* tracer finish
* <p>
* Transaction must have two txas due to the Segment being finished on another thread.
* Segment tracer must correctly link to root tracer.
*/
@Test
public void testAsyncNamedTracedActivity() throws InterruptedException {
final Tracer root = makeTransaction();
Assert.assertNotNull(root);
Assert.assertNotNull(root.getTransactionActivity().getTransaction());
Thread.sleep(1);
final TracedActivity activity = AgentBridge.getAgent().getTransaction().createAndStartTracedActivity();
Assert.assertNotNull(activity);
final AtomicReference<TracedMethod> tracedMethod = new AtomicReference<>();
Thread t = new Thread() {
@Override
public void run() {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
tracedMethod.set(activity.getTracedMethod());
activity.end();
}
};
t.start();
t.join();
root.finish(Opcodes.ARETURN, null);
// assert num children == 2
assertTrue(root.getTransactionActivity().getTransaction().isFinished());
assertTrue(tracedMethod.get() instanceof Tracer);
assertEquals("Transaction activity context was not properly set", "activity", ((Tracer) tracedMethod.get()).getTransactionActivity().getAsyncContext());
assertEquals("Segment name not set properly", "Custom/Unnamed Segment", ((Tracer) tracedMethod.get()).getMetricName());
assertEquals(2, root.getTransactionActivity().getTransaction().getCountOfRunningAndFinishedTransactionActivities());
assertEquals(2, getNumTracers(root.getTransactionActivity().getTransaction()));
Assert.assertSame("Segment must be child of root tracer", root, tracedMethod.get().getParentTracedMethod());
}
Aggregations