Search in sources :

Example 86 with Segment

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

the class HttpExtInstrumentation method singleRequestImpl.

// We are weaving the singleRequestImpl method here rather than just singleRequest because the javadsl only flows through here
public Future<HttpResponse> singleRequestImpl(HttpRequest httpRequest, HttpsConnectionContext connectionContext, ConnectionPoolSettings poolSettings, LoggingAdapter loggingAdapter) {
    final Segment segment = NewRelic.getAgent().getTransaction().startSegment("Akka", "singleRequest");
    Future<HttpResponse> responseFuture = Weaver.callOriginal();
    AkkaHttpUtils.finishSegmentOnComplete(httpRequest, responseFuture, segment);
    return responseFuture;
}
Also used : HttpResponse(akka.http.scaladsl.model.HttpResponse) Segment(com.newrelic.api.agent.Segment)

Example 87 with Segment

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

the class HttpClientImpl_Instrumentation method sendAsync.

@Trace
public <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest userRequest, HttpResponse.BodyHandler<T> responseHandler, HttpResponse.PushPromiseHandler<T> pushPromiseHandler) {
    URI uri = userRequest.uri();
    Segment segment = startSegment(uri);
    CompletableFuture<HttpResponse<T>> completableFutureResponse = Weaver.callOriginal();
    if (segment == null) {
        return completableFutureResponse;
    }
    return completableFutureResponse.whenComplete(Java11HttpClientUtil.reportAsExternal(uri, segment));
}
Also used : HttpResponse(java.net.http.HttpResponse) URI(java.net.URI) Segment(com.newrelic.api.agent.Segment) Trace(com.newrelic.api.agent.Trace)

Example 88 with Segment

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

the class ClientCalls_Instrumentation method startCall.

private static <ReqT, RespT> void startCall(ClientCall_Instrumentation<ReqT, RespT> call, ClientCall_Instrumentation.Listener<RespT> responseListener, boolean streamingResponse) {
    Segment segment = NewRelic.getAgent().getTransaction().startSegment("gRPC", "External");
    call.segment = segment;
    Weaver.callOriginal();
    responseListener.segment = segment;
    responseListener.authority = call.authority;
    responseListener.methodDescriptor = call.methodDescriptor;
}
Also used : Segment(com.newrelic.api.agent.Segment)

Example 89 with Segment

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

the class AbstractRedisAsyncCommands_Instrumentation method dispatch.

@SuppressWarnings("unchecked")
@Trace
public <T> AsyncCommand<K, V, T> dispatch(RedisCommand<K, V, T> cmd) {
    AsyncCommand<K, V, T> acmd = Weaver.callOriginal();
    String collName = "?";
    RedisURI uri = null;
    StatefulConnection<K, V> conn = getConnection();
    if (StatefulRedisConnectionImpl_Instrumentation.class.isInstance(conn)) {
        StatefulRedisConnectionImpl_Instrumentation<K, V> connImpl = (StatefulRedisConnectionImpl_Instrumentation<K, V>) conn;
        if (connImpl.redisURI != null) {
            uri = connImpl.redisURI;
        }
    }
    String operation = "UnknownOp";
    ProtocolKeyword t = cmd.getType();
    if (t != null && t.name() != null && !t.name().isEmpty()) {
        operation = t.name();
    }
    DatastoreParameters params = null;
    if (uri != null) {
        params = DatastoreParameters.product("Redis").collection(collName).operation(operation).instance(uri.getHost(), uri.getPort()).noDatabaseName().build();
    } else {
        params = DatastoreParameters.product("Redis").collection(collName).operation("").noInstance().noDatabaseName().noSlowQuery().build();
    }
    Segment segment = NewRelic.getAgent().getTransaction().startSegment("Lettuce", operation);
    NRBiConsumer<T> nrBiConsumer = new NRBiConsumer<T>(segment, params);
    acmd.whenComplete(nrBiConsumer);
    return acmd;
}
Also used : NRBiConsumer(com.nr.lettuce43.instrumentation.NRBiConsumer) DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) Segment(com.newrelic.api.agent.Segment) ProtocolKeyword(com.lambdaworks.redis.protocol.ProtocolKeyword) Trace(com.newrelic.api.agent.Trace)

Example 90 with Segment

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

the class AbstractRedisAsyncCommands_Instrumentation method dispatch.

@SuppressWarnings("unchecked")
@Trace
public <T> AsyncCommand<K, V, T> dispatch(RedisCommand<K, V, T> cmd) {
    AsyncCommand<K, V, T> acmd = Weaver.callOriginal();
    RedisURI uri = null;
    StatefulConnection<K, V> conn = getConnection();
    if (StatefulRedisConnectionImpl_Instrumentation.class.isInstance(conn)) {
        StatefulRedisConnectionImpl_Instrumentation<K, V> connImpl = (StatefulRedisConnectionImpl_Instrumentation<K, V>) conn;
        if (connImpl.redisURI != null) {
            uri = connImpl.redisURI;
        }
    }
    String operation = "UnknownOp";
    ProtocolKeyword t = cmd.getType();
    if (t != null && t.name() != null && !t.name().isEmpty()) {
        operation = t.name();
    }
    if (operation.equalsIgnoreCase("expire")) {
        return acmd;
    }
    DatastoreParameters params;
    if (uri != null) {
        params = DatastoreParameters.product("Redis").collection(null).operation(operation).instance(uri.getHost(), uri.getPort()).noDatabaseName().build();
    } else {
        params = DatastoreParameters.product("Redis").collection(null).operation("").noInstance().noDatabaseName().noSlowQuery().build();
    }
    Segment segment = NewRelic.getAgent().getTransaction().startSegment("Redis", operation);
    NRBiConsumer<T> nrBiConsumer = new NRBiConsumer<T>(segment, params);
    acmd.whenComplete(nrBiConsumer);
    return acmd;
}
Also used : NRBiConsumer(com.nr.lettuce6.instrumentation.NRBiConsumer) DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) Segment(com.newrelic.api.agent.Segment) ProtocolKeyword(io.lettuce.core.protocol.ProtocolKeyword) Trace(com.newrelic.api.agent.Trace)

Aggregations

Segment (com.newrelic.api.agent.Segment)138 Trace (com.newrelic.api.agent.Trace)13 URI (java.net.URI)6 NoOpSegment (com.newrelic.agent.bridge.NoOpSegment)5 URISyntaxException (java.net.URISyntaxException)4 HttpResponse (akka.http.scaladsl.model.HttpResponse)3 Transaction (com.newrelic.agent.bridge.Transaction)3 DatastoreParameters (com.newrelic.api.agent.DatastoreParameters)3 ExternalParameters (com.newrelic.api.agent.ExternalParameters)3 InetSocketAddress (java.net.InetSocketAddress)3 Test (org.junit.Test)3 Transaction (com.newrelic.agent.Transaction)2 MessageProduceParameters (com.newrelic.api.agent.MessageProduceParameters)2 Transaction (com.newrelic.api.agent.Transaction)2 OutboundWrapper (com.nr.agent.instrumentation.asynchttpclient.OutboundWrapper)2 HelloReply (io.grpc.examples.helloworld.HelloReply)2 HelloRequest (io.grpc.examples.helloworld.HelloRequest)2 IOException (java.io.IOException)2 SocketAddress (java.net.SocketAddress)2 MemcachedNode (net.spy.memcached.MemcachedNode)2