use of org.apache.activemq.ActiveMQSession in project pinpoint by naver.
the class ActiveMQMessageProducerSendInterceptor 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;
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
if (throwable == null) {
ActiveMQDestination destination = (ActiveMQDestination) args[0];
// This annotation indicates the uri to which the call is made
recorder.recordAttribute(AnnotationKey.MESSAGE_QUEUE_URI, destination.getQualifiedName());
// DestinationId is used to render the virtual queue node.
// We choose the queue/topic name as the logical name of the queue node.
recorder.recordDestinationId(destination.getPhysicalName());
ActiveMQSession session = ((ActiveMQSessionGetter) target)._$PINPOINT$_getActiveMQSession();
ActiveMQConnection connection = session.getConnection();
Transport transport = getRootTransport(((TransportGetter) connection)._$PINPOINT$_getTransport());
Socket socket = ((SocketGetter) transport)._$PINPOINT$_getSocket();
SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
String remoteAddress = ActiveMQClientUtils.getEndPoint(remoteSocketAddress);
// Producer's endPoint should be the socket address of where the producer is actually connected to.
recorder.recordEndPoint(remoteAddress);
recorder.recordAttribute(ActiveMQClientConstants.ACTIVEMQ_BROKER_URL, remoteAddress);
} else {
recorder.recordException(throwable);
}
} catch (Throwable t) {
logger.warn("AFTER error. Cause:{}", t.getMessage(), t);
} finally {
trace.traceBlockEnd();
}
}
Aggregations