use of com.navercorp.pinpoint.plugin.rabbitmq.client.field.accessor.LocalAddressAccessor in project pinpoint by naver.
the class RabbitMQConsumerHandleCompleteInboundCommandInterceptor method recordRootSpan.
private void recordRootSpan(SpanRecorder recorder, AMQConnection amqConnection, String exchange, String routingKey, Map<String, Object> headers) {
recorder.recordServiceType(RabbitMQClientConstants.RABBITMQ_CLIENT);
recorder.recordApi(CONSUMER_ENTRY_METHOD_DESCRIPTOR);
String endPoint = RabbitMQClientConstants.UNKNOWN;
String remoteAddress = RabbitMQClientConstants.UNKNOWN;
if (amqConnection != null) {
FrameHandler frameHandler = amqConnection.getFrameHandler();
// Endpoint should be the local socket address of the consumer.
if (frameHandler instanceof LocalAddressAccessor) {
endPoint = ((LocalAddressAccessor) frameHandler)._$PINPOINT$_getLocalAddress();
}
// Remote address is the socket address of where the consumer is connected to.
if (frameHandler instanceof RemoteAddressAccessor) {
remoteAddress = ((RemoteAddressAccessor) frameHandler)._$PINPOINT$_getRemoteAddress();
}
}
recorder.recordEndPoint(endPoint);
recorder.recordRemoteAddress(remoteAddress);
String convertedExchange = StringUtils.defaultIfEmpty(exchange, RabbitMQClientConstants.UNKNOWN);
recorder.recordRpcName("rabbitmq://exchange=" + convertedExchange);
recorder.recordAcceptorHost("exchange-" + convertedExchange);
if (isDebug) {
logger.debug("endPoint={}->{}", exchange, convertedExchange);
}
recorder.recordAttribute(RabbitMQClientConstants.RABBITMQ_ROUTINGKEY_ANNOTATION_KEY, routingKey);
if (MapUtils.hasLength(headers)) {
Object parentApplicationName = headers.get(RabbitMQClientConstants.META_PARENT_APPLICATION_NAME);
if (!recorder.isRoot() && parentApplicationName != null) {
Object parentApplicationType = headers.get(RabbitMQClientConstants.META_PARENT_APPLICATION_TYPE);
recorder.recordParentApplication(parentApplicationName.toString(), NumberUtils.parseShort(parentApplicationType.toString(), ServiceType.UNDEFINED.getCode()));
}
}
}
use of com.navercorp.pinpoint.plugin.rabbitmq.client.field.accessor.LocalAddressAccessor in project pinpoint by naver.
the class SocketFrameHandlerConstructInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (!validate(target, args)) {
return;
}
String localAddress = RabbitMQClientConstants.UNKNOWN;
String remoteAddress = RabbitMQClientConstants.UNKNOWN;
if (args[0] instanceof Socket) {
Socket socket = (Socket) args[0];
localAddress = HostAndPort.toHostAndPortString(socket.getLocalAddress().getHostAddress(), socket.getLocalPort());
remoteAddress = HostAndPort.toHostAndPortString(socket.getInetAddress().getHostAddress(), socket.getPort());
}
((LocalAddressAccessor) target)._$PINPOINT$_setLocalAddress(localAddress);
((RemoteAddressAccessor) target)._$PINPOINT$_setRemoteAddress(remoteAddress);
}
use of com.navercorp.pinpoint.plugin.rabbitmq.client.field.accessor.LocalAddressAccessor in project pinpoint by naver.
the class RabbitMQConsumerDispatchInterceptor method recordRootSpan.
private void recordRootSpan(SpanRecorder recorder, Connection connection, Envelope envelope, Map<String, Object> headers) {
recorder.recordServiceType(RabbitMQClientConstants.RABBITMQ_CLIENT);
recorder.recordApi(CONSUMER_ENTRY_METHOD_DESCRIPTOR);
String endPoint = RabbitMQClientConstants.UNKNOWN;
String remoteAddress = RabbitMQClientConstants.UNKNOWN;
if (connection instanceof AMQConnection) {
AMQConnection amqConnection = (AMQConnection) connection;
FrameHandler frameHandler = amqConnection.getFrameHandler();
// Endpoint should be the local socket address of the consumer.
if (frameHandler instanceof LocalAddressAccessor) {
endPoint = ((LocalAddressAccessor) frameHandler)._$PINPOINT$_getLocalAddress();
}
// Remote address is the socket address of where the consumer is connected to.
if (frameHandler instanceof RemoteAddressAccessor) {
remoteAddress = ((RemoteAddressAccessor) frameHandler)._$PINPOINT$_getRemoteAddress();
}
}
recorder.recordEndPoint(endPoint);
recorder.recordRemoteAddress(remoteAddress);
String exchange = StringUtils.defaultIfEmpty(envelope.getExchange(), RabbitMQClientConstants.UNKNOWN);
recorder.recordRpcName("rabbitmq://exchange=" + exchange);
recorder.recordAcceptorHost("exchange-" + exchange);
if (isDebug) {
logger.debug("endPoint={}->{}", envelope.getExchange(), exchange);
}
recorder.recordAttribute(RabbitMQClientConstants.RABBITMQ_ROUTINGKEY_ANNOTATION_KEY, envelope.getRoutingKey());
if (MapUtils.hasLength(headers)) {
Object parentApplicationName = headers.get(RabbitMQClientConstants.META_PARENT_APPLICATION_NAME);
if (!recorder.isRoot() && parentApplicationName != null) {
Object parentApplicationType = headers.get(RabbitMQClientConstants.META_PARENT_APPLICATION_TYPE);
recorder.recordParentApplication(parentApplicationName.toString(), NumberUtils.parseShort(parentApplicationType.toString(), ServiceType.UNDEFINED.getCode()));
}
}
}
use of com.navercorp.pinpoint.plugin.rabbitmq.client.field.accessor.LocalAddressAccessor in project pinpoint by naver.
the class SocketChannelFrameHandlerConstructInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (!validate(target)) {
return;
}
String localAddress = RabbitMQClientConstants.UNKNOWN;
String remoteAddress = RabbitMQClientConstants.UNKNOWN;
if (target instanceof SocketChannelFrameHandler) {
SocketChannelFrameHandler frameHandler = (SocketChannelFrameHandler) target;
localAddress = HostAndPort.toHostAndPortString(frameHandler.getLocalAddress().getHostAddress(), frameHandler.getLocalPort());
remoteAddress = HostAndPort.toHostAndPortString(frameHandler.getAddress().getHostAddress(), frameHandler.getPort());
}
((LocalAddressAccessor) target)._$PINPOINT$_setLocalAddress(localAddress);
((RemoteAddressAccessor) target)._$PINPOINT$_setRemoteAddress(remoteAddress);
}
Aggregations