use of com.newrelic.api.agent.Transaction in project newrelic-java-agent by newrelic.
the class SnsClientInstrumentationHelper method startSegmentAndReportAsExternal.
public static Segment startSegmentAndReportAsExternal(PublishRequest publishRequest) {
Transaction transaction = NewRelic.getAgent().getTransaction();
Segment segment = transaction.startSegment("SNS");
MessageProduceParameters params = SnsClientInstrumentationHelper.makeMessageProducerParameters(publishRequest);
segment.reportAsExternal(params);
return segment;
}
use of com.newrelic.api.agent.Transaction in project newrelic-java-agent by newrelic.
the class ServerStream_Instrumentation method cancel.
// server had an internal error
@Trace(async = true)
public void cancel(Status status) {
if (token != null) {
token.link();
Transaction transaction = token.getTransaction();
transaction.setWebResponse(new GrpcResponse(status, new Metadata()));
transaction.addOutboundResponseHeaders();
transaction.markResponseSent();
}
if (status != null) {
NewRelic.addCustomParameter("response.status", status.getCode().value());
if (GrpcConfig.errorsEnabled && status.getCause() != null) {
// If an error occurred during the close of this server call we should record it
NewRelic.noticeError(status.getCause());
}
}
Weaver.callOriginal();
if (token != null) {
token.expire();
token = null;
}
}
use of com.newrelic.api.agent.Transaction in project newrelic-java-agent by newrelic.
the class AsyncHttpClient_Instrumentation method executeRequest.
public <T> ListenableFuture<T> executeRequest(Request request, AsyncHandler_Instrumentation<T> handler) {
URI uri = null;
try {
uri = new URI(request.getUrl());
String scheme = uri.getScheme().toLowerCase();
// only instrument HTTP or HTTPS calls
if ("http".equals(scheme) || "https".equals(scheme)) {
Transaction txn = AgentBridge.getAgent().getTransaction(false);
if (txn != null) {
handler.token = txn.getToken();
}
}
} catch (URISyntaxException uriSyntaxException) {
// if Java can't parse the URI, asynchttpclient won't be able to either
// let's just proceed without instrumentation
}
return Weaver.callOriginal();
}
Aggregations