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;
}
Aggregations