Search in sources :

Example 6 with Transaction

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;
}
Also used : Transaction(com.newrelic.api.agent.Transaction) MessageProduceParameters(com.newrelic.api.agent.MessageProduceParameters) Segment(com.newrelic.api.agent.Segment)

Example 7 with Transaction

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;
    }
}
Also used : Transaction(com.newrelic.api.agent.Transaction) Metadata(io.grpc.Metadata) GrpcResponse(com.nr.agent.instrumentation.grpc.GrpcResponse) Trace(com.newrelic.api.agent.Trace)

Example 8 with Transaction

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();
}
Also used : Transaction(com.newrelic.api.agent.Transaction) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

Transaction (com.newrelic.api.agent.Transaction)8 Trace (com.newrelic.api.agent.Trace)5 Segment (com.newrelic.api.agent.Segment)2 GrpcResponse (com.nr.agent.instrumentation.grpc.GrpcResponse)2 URISyntaxException (java.net.URISyntaxException)2 ResponseWrapper (com.agent.instrumentation.akka.http.ResponseWrapper)1 PublishRequest (com.amazonaws.services.sns.model.PublishRequest)1 PublishResult (com.amazonaws.services.sns.model.PublishResult)1 TransactionApiImpl (com.newrelic.agent.TransactionApiImpl)1 ExitTracer (com.newrelic.agent.bridge.ExitTracer)1 NoOpTransaction (com.newrelic.agent.bridge.NoOpTransaction)1 InstrumentationImpl (com.newrelic.agent.instrumentation.InstrumentationImpl)1 MessageProduceParameters (com.newrelic.api.agent.MessageProduceParameters)1 Metadata (io.grpc.Metadata)1 IOException (java.io.IOException)1 URI (java.net.URI)1