Search in sources :

Example 6 with FrameHandler

use of com.rabbitmq.client.impl.FrameHandler in project pinpoint by naver.

the class ChannelBasicPublishInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args);
    }
    if (!validate(target, args)) {
        return;
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        String exchange = (String) args[0];
        String routingKey = (String) args[1];
        if (exchange == null || exchange.equals("")) {
            exchange = RabbitMQClientConstants.UNKNOWN;
        }
        SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(descriptor);
        String endPoint = RabbitMQClientConstants.UNKNOWN;
        // Producer's endPoint should be the socket address of where the producer is actually connected to.
        final Connection connection = ((Channel) target).getConnection();
        if (connection instanceof AMQConnection) {
            AMQConnection amqConnection = (AMQConnection) connection;
            FrameHandler frameHandler = amqConnection.getFrameHandler();
            if (frameHandler instanceof RemoteAddressAccessor) {
                endPoint = ((RemoteAddressAccessor) frameHandler)._$PINPOINT$_getRemoteAddress();
            }
        }
        recorder.recordEndPoint(endPoint);
        // DestinationId is used to render the virtual queue node.
        // We choose the exchange name as the logical name of the queue node.
        recorder.recordDestinationId("exchange-" + exchange);
        recorder.recordAttribute(RabbitMQClientConstants.RABBITMQ_EXCHANGE_ANNOTATION_KEY, exchange);
        recorder.recordAttribute(RabbitMQClientConstants.RABBITMQ_ROUTINGKEY_ANNOTATION_KEY, routingKey);
        recorder.recordException(throwable);
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) FrameHandler(com.rabbitmq.client.impl.FrameHandler) AMQConnection(com.rabbitmq.client.impl.AMQConnection) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) Channel(com.rabbitmq.client.Channel) AMQConnection(com.rabbitmq.client.impl.AMQConnection) Connection(com.rabbitmq.client.Connection) RemoteAddressAccessor(com.navercorp.pinpoint.plugin.rabbitmq.client.field.accessor.RemoteAddressAccessor)

Aggregations

FrameHandler (com.rabbitmq.client.impl.FrameHandler)6 RemoteAddressAccessor (com.navercorp.pinpoint.plugin.rabbitmq.client.field.accessor.RemoteAddressAccessor)3 Connection (com.rabbitmq.client.Connection)3 AMQConnection (com.rabbitmq.client.impl.AMQConnection)3 LocalAddressAccessor (com.navercorp.pinpoint.plugin.rabbitmq.client.field.accessor.LocalAddressAccessor)2 Address (com.rabbitmq.client.Address)2 MetricsCollector (com.rabbitmq.client.MetricsCollector)2 ConnectionParams (com.rabbitmq.client.impl.ConnectionParams)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 Test (org.junit.Test)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 AddressResolver (com.rabbitmq.client.AddressResolver)1 Channel (com.rabbitmq.client.Channel)1 ConnectionFactory (com.rabbitmq.client.ConnectionFactory)1 FrameHandlerFactory (com.rabbitmq.client.impl.FrameHandlerFactory)1 RecoveryAwareAMQConnection (com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnection)1 RecoveryAwareAMQConnectionFactory (com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory)1 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1