Search in sources :

Example 1 with NRSignalTypeConsumer

use of com.nr.lettuce6.instrumentation.NRSignalTypeConsumer in project newrelic-java-agent by newrelic.

the class AbstractRedisReactiveCommands_Instrumentation method createDissolvingFlux.

public <T, R> Flux<R> createDissolvingFlux(Supplier<RedisCommand<K, V, T>> commandSupplier) {
    Flux<R> result = Weaver.callOriginal();
    RedisCommand<K, V, T> cmd = commandSupplier.get();
    if (cmd != null) {
        ProtocolKeyword type = cmd.getType();
        String name = type.name();
        String collName = null;
        RedisURI uri = null;
        if (StatefulRedisConnectionImpl_Instrumentation.class.isInstance(connection)) {
            StatefulRedisConnectionImpl_Instrumentation<K, V> connImpl = (StatefulRedisConnectionImpl_Instrumentation<K, V>) connection;
            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(), Integer.valueOf(uri.getPort())).noDatabaseName().build();
        } else {
            params = DatastoreParameters.product("Redis").collection(collName).operation("").noInstance().noDatabaseName().noSlowQuery().build();
        }
        NRHolder holder = new NRHolder(name, params);
        NRSubscribeConsumer subscriberConsumer = new NRSubscribeConsumer(holder);
        NRErrorConsumer errorConsumer = new NRErrorConsumer(holder);
        Consumer<SignalType> onFinally = new NRSignalTypeConsumer(holder);
        return result.doOnSubscribe(subscriberConsumer).doOnError(errorConsumer).doFinally(onFinally);
    }
    return result;
}
Also used : SignalType(reactor.core.publisher.SignalType) DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) NRErrorConsumer(com.nr.lettuce6.instrumentation.NRErrorConsumer) NRSubscribeConsumer(com.nr.lettuce6.instrumentation.NRSubscribeConsumer) NRHolder(com.nr.lettuce6.instrumentation.NRHolder) NRSignalTypeConsumer(com.nr.lettuce6.instrumentation.NRSignalTypeConsumer) ProtocolKeyword(io.lettuce.core.protocol.ProtocolKeyword)

Example 2 with NRSignalTypeConsumer

use of com.nr.lettuce6.instrumentation.NRSignalTypeConsumer in project newrelic-java-agent by newrelic.

the class AbstractRedisReactiveCommands_Instrumentation method createMono.

public <T> Mono<T> createMono(Supplier<RedisCommand<K, V, T>> commandSupplier) {
    Mono<T> result = Weaver.callOriginal();
    RedisCommand<K, V, T> cmd = commandSupplier.get();
    if (cmd != null) {
        ProtocolKeyword type = cmd.getType();
        String name = type.name();
        String collName = null;
        RedisURI uri = null;
        if (StatefulRedisConnectionImpl_Instrumentation.class.isInstance(connection)) {
            StatefulRedisConnectionImpl_Instrumentation<K, V> connImpl = (StatefulRedisConnectionImpl_Instrumentation<K, V>) connection;
            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(), Integer.valueOf(uri.getPort())).noDatabaseName().build();
        } else {
            params = DatastoreParameters.product("Redis").collection(collName).operation(operation).noInstance().noDatabaseName().noSlowQuery().build();
        }
        NRHolder holder = new NRHolder(name, params);
        NRSubscribeConsumer subscriberConsumer = new NRSubscribeConsumer(holder);
        NRErrorConsumer errorConsumer = new NRErrorConsumer(holder);
        Consumer<SignalType> onFinally = new NRSignalTypeConsumer(holder);
        return result.doOnSubscribe(subscriberConsumer).doOnError(errorConsumer).doFinally(onFinally);
    }
    return result;
}
Also used : SignalType(reactor.core.publisher.SignalType) DatastoreParameters(com.newrelic.api.agent.DatastoreParameters) NRErrorConsumer(com.nr.lettuce6.instrumentation.NRErrorConsumer) NRSubscribeConsumer(com.nr.lettuce6.instrumentation.NRSubscribeConsumer) NRHolder(com.nr.lettuce6.instrumentation.NRHolder) NRSignalTypeConsumer(com.nr.lettuce6.instrumentation.NRSignalTypeConsumer) ProtocolKeyword(io.lettuce.core.protocol.ProtocolKeyword)

Aggregations

DatastoreParameters (com.newrelic.api.agent.DatastoreParameters)2 NRErrorConsumer (com.nr.lettuce6.instrumentation.NRErrorConsumer)2 NRHolder (com.nr.lettuce6.instrumentation.NRHolder)2 NRSignalTypeConsumer (com.nr.lettuce6.instrumentation.NRSignalTypeConsumer)2 NRSubscribeConsumer (com.nr.lettuce6.instrumentation.NRSubscribeConsumer)2 ProtocolKeyword (io.lettuce.core.protocol.ProtocolKeyword)2 SignalType (reactor.core.publisher.SignalType)2