use of com.rabbitmq.client.impl.Method in project pinpoint by naver.
the class RabbitMQConsumerHandleCompleteInboundCommandInterceptor method createTrace.
private Trace createTrace(AMQChannel amqChannel, AMQCommand amqCommand) {
AMQConnection connection = amqChannel.getConnection();
if (connection == null) {
logger.debug("connection is null, skipping trace");
}
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;
}
use of com.rabbitmq.client.impl.Method in project pinpoint by naver.
the class RabbitMQConsumerHandleCompleteInboundCommandInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (!validate(target, args)) {
return;
}
AMQCommand command = (AMQCommand) args[0];
Method method = command.getMethod();
if (!(method instanceof AMQP.Basic.GetOk)) {
return;
}
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
return;
}
if (!trace.canSampled()) {
traceContext.removeTraceObject();
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(methodDescriptor);
if (throwable != null) {
recorder.recordException(throwable);
}
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER. Caused:{}", th.getMessage(), th);
}
} finally {
traceContext.removeTraceObject();
trace.traceBlockEnd();
trace.close();
}
}
use of com.rabbitmq.client.impl.Method in project pinpoint by naver.
the class RabbitMQConsumerHandleCompleteInboundCommandInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (!validate(target, args)) {
return;
}
AMQCommand command = (AMQCommand) args[0];
Method method = command.getMethod();
if (!(method instanceof AMQP.Basic.GetOk)) {
return;
}
if (isDebug) {
logger.beforeInterceptor(target, args);
}
try {
AMQChannel channel = (AMQChannel) target;
final Trace trace = createTrace(channel, command);
if (trace == null) {
return;
}
if (!trace.canSampled()) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(RabbitMQClientConstants.RABBITMQ_CLIENT_INTERNAL);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
}
}
}
Aggregations