Example usage for com.rabbitmq.client.impl AMQCommand getContentHeader

List of usage examples for com.rabbitmq.client.impl AMQCommand getContentHeader

Introduction

In this page you can find the example usage for com.rabbitmq.client.impl AMQCommand getContentHeader.

Prototype

@Override
public AMQContentHeader getContentHeader() 

Source Link

Document

Public API -

Usage

From source file:com.navercorp.pinpoint.plugin.rabbitmq.client.interceptor.RabbitMQConsumerHandleCompleteInboundCommandInterceptor.java

License:Apache License

private Trace createTrace(AMQChannel amqChannel, AMQCommand amqCommand) {
    AMQConnection connection = amqChannel.getConnection();
    if (connection == null) {
        logger.debug("connection is null, skipping trace");
    }/*from   ww w. ja va 2 s. c o m*/

    Method method = amqCommand.getMethod();
    AMQP.Basic.GetOk getOk = (AMQP.Basic.GetOk) method;
    String exchange = getOk.getExchange();
    if (RabbitMQClientPluginConfig.isExchangeExcluded(exchange, excludeExchangeFilter)) {
        if (isDebug) {
            logger.debug("exchange {} is excluded", exchange);
        }
        return null;
    }
    String routingKey = getOk.getRoutingKey();

    Map<String, Object> headers = getHeadersFromContentHeader(amqCommand.getContentHeader());

    // 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, exchange, routingKey, headers);
    }
    return trace;
}