Search in sources :

Example 1 with ChannelGetter

use of com.navercorp.pinpoint.plugin.rabbitmq.client.field.getter.ChannelGetter in project pinpoint by naver.

the class RabbitMQConsumerDispatchInterceptor method createTrace.

private Trace createTrace(Object target, Object[] args) {
    final Channel channel = ((ChannelGetter) target)._$PINPOINT$_getChannel();
    if (channel == null) {
        logger.debug("channel is null, skipping trace");
        return null;
    }
    final Connection connection = channel.getConnection();
    if (connection == null) {
        logger.debug("connection is null, skipping trace");
        return null;
    }
    Envelope envelope = ArrayArgumentUtils.getArgument(args, 2, Envelope.class);
    String exchange = envelope.getExchange();
    if (RabbitMQClientPluginConfig.isExchangeExcluded(exchange, excludeExchangeFilter)) {
        if (isDebug) {
            logger.debug("exchange {} is excluded", exchange);
        }
        return null;
    }
    // args[3] may be null
    AMQP.BasicProperties properties = (AMQP.BasicProperties) args[3];
    Map<String, Object> headers = getHeadersFromBasicProperties(properties);
    // If this transaction is not traceable, mark as disabled.
    if (headers.get(RabbitMQClientConstants.META_SAMPLED) != null) {
        return traceContext.disableSampling();
    }
    final TraceId traceId = populateTraceIdFromRequest(headers);
    // If there's no trasanction id, a new trasaction begins here.
    final Trace trace = traceId == null ? traceContext.newTraceObject() : traceContext.continueTraceObject(traceId);
    if (trace.canSampled()) {
        final SpanRecorder recorder = trace.getSpanRecorder();
        recordRootSpan(recorder, connection, envelope, headers);
    }
    return trace;
}
Also used : Channel(com.rabbitmq.client.Channel) Connection(com.rabbitmq.client.Connection) AMQConnection(com.rabbitmq.client.impl.AMQConnection) Envelope(com.rabbitmq.client.Envelope) Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) AMQP(com.rabbitmq.client.AMQP) ChannelGetter(com.navercorp.pinpoint.plugin.rabbitmq.client.field.getter.ChannelGetter) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId)

Aggregations

SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 ChannelGetter (com.navercorp.pinpoint.plugin.rabbitmq.client.field.getter.ChannelGetter)1 AMQP (com.rabbitmq.client.AMQP)1 Channel (com.rabbitmq.client.Channel)1 Connection (com.rabbitmq.client.Connection)1 Envelope (com.rabbitmq.client.Envelope)1 AMQConnection (com.rabbitmq.client.impl.AMQConnection)1