Search in sources :

Example 1 with GrpcResponse

use of com.nr.agent.instrumentation.grpc.GrpcResponse in project newrelic-java-agent by newrelic.

the class ServerStream_Instrumentation method close.

@Trace(async = true)
public void close(Status status, Metadata trailers) {
    if (token != null) {
        token.link();
        Transaction transaction = NewRelic.getAgent().getTransaction();
        transaction.setWebResponse(new GrpcResponse(status, trailers));
        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) GrpcResponse(com.nr.agent.instrumentation.grpc.GrpcResponse) Trace(com.newrelic.api.agent.Trace)

Example 2 with GrpcResponse

use of com.nr.agent.instrumentation.grpc.GrpcResponse 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)

Aggregations

Trace (com.newrelic.api.agent.Trace)2 Transaction (com.newrelic.api.agent.Transaction)2 GrpcResponse (com.nr.agent.instrumentation.grpc.GrpcResponse)2 Metadata (io.grpc.Metadata)1