use of reactor.netty.channel.ChannelOperations in project pinpoint by naver.
the class HttpClientHandlerRequestWithBodyInterceptor method doInBeforeTrace.
@Override
public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContext, Object target, Object[] args) {
if (ArrayUtils.isEmpty(args)) {
// Skip
return;
}
// Set HttpClientOptions
if (args[0] instanceof AsyncContextAccessor) {
((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
}
// Set hostname
if (args[0] instanceof ChannelOperations) {
try {
final ChannelOperations channelOperations = (ChannelOperations) args[0];
final InetSocketAddress inetSocketAddress = (InetSocketAddress) channelOperations.channel().remoteAddress();
if (inetSocketAddress != null) {
final String hostName = SocketAddressUtils.getHostNameFirst(inetSocketAddress);
if (hostName != null) {
recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, HostAndPort.toHostAndPortString(hostName, inetSocketAddress.getPort()));
}
}
} catch (Exception ignore) {
}
}
}
use of reactor.netty.channel.ChannelOperations in project pinpoint by naver.
the class HttpClientRequestWrapper method toRemoteHost.
private String toRemoteHost() {
if (request instanceof ChannelOperations) {
try {
final ChannelOperations channelOperations = (ChannelOperations) request;
final InetSocketAddress inetSocketAddress = (InetSocketAddress) channelOperations.channel().remoteAddress();
if (inetSocketAddress != null) {
final StringBuilder sb = new StringBuilder();
final String hostName = SocketAddressUtils.getHostNameFirst(inetSocketAddress);
if (hostName != null) {
sb.append(hostName).append(":").append(inetSocketAddress.getPort());
}
return sb.toString();
}
} catch (Exception ignored) {
}
}
return null;
}
Aggregations