Search in sources :

Example 1 with NRBiConsumer

use of com.nr.lettuce43.instrumentation.NRBiConsumer 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 2 with NRBiConsumer

use of com.nr.lettuce43.instrumentation.NRBiConsumer 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

DatastoreParameters (com.newrelic.api.agent.DatastoreParameters)2 Segment (com.newrelic.api.agent.Segment)2 Trace (com.newrelic.api.agent.Trace)2 ProtocolKeyword (com.lambdaworks.redis.protocol.ProtocolKeyword)1 NRBiConsumer (com.nr.lettuce43.instrumentation.NRBiConsumer)1 NRBiConsumer (com.nr.lettuce6.instrumentation.NRBiConsumer)1 ProtocolKeyword (io.lettuce.core.protocol.ProtocolKeyword)1