Pinpoint: Can we also trace the netty client and server?

Created on 27 Sep 2016  ·  4Comments  ·  Source: pinpoint-apm/pinpoint

@Xylus Can we also trace the netty client and netty server?

``````
Server:
@Override
public void start() {
LOGGER.info("Bind Local Port {} [Netty]", port);

    new Thread("NettyContainer-Thread") {
        @Override
        public void run() {
            try {
                bootstrap = new ServerBootstrap();

                bootstrap.group(bossGroup, workerGroup)
                        .channel(NioServerSocketChannel.class)
                        .childHandler(new ChannelInitializer<SocketChannel>() {
                            @Override
                            protected void initChannel(SocketChannel ch) throws Exception {
                                ch.pipeline().addLast(new IdleStateHandler(15, 0, 0), new SoaDecoder(), new SoaIdleHandler(), new SoaServerHandler(ProcessorCache.getProcessorMap()));
                            }
                        })
                        .option(ChannelOption.SO_BACKLOG, 1024)
                        .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)//重复利用之前分配的内存空间(PooledByteBuf -> ByteBuf)
                        .childOption(ChannelOption.SO_KEEPALIVE, true)
                        .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);

                // Start the server.
                ChannelFuture f = bootstrap.bind(port).sync();

                // Wait until the connection is closed.
                f.channel().closeFuture().sync();
            } catch (InterruptedException e) {
                LOGGER.error(e.getMessage(), e);
            } finally {
                workerGroup.shutdownGracefully();
                bossGroup.shutdownGracefully();
            }
        }
    }.start();
}```

Client:

b = new Bootstrap();
b.group(workerGroup);
b.channel(NioSocketChannel.class);
b.option(ChannelOption.SO_KEEPALIVE, true);
b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
b.handler(new ChannelInitializer() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new IdleStateHandler(readerIdleTimeSeconds, writerIdleTimeSeconds, allIdleTimeSeconds), new SoaDecoder(), new SoaIdleHandler(), new SoaClientHandler(callBack));
}
});
return b;

For more information, could you refer to the https://github.com/isuwang/isuwang-soa/blob/master/dapeng-container/src/main/java/com/isuwang/dapeng/container/netty/NettyContainer.java

https://github.com/isuwang/isuwang-soa/blob/master/dapeng-remoting/dapeng-remoting-netty/src/main/java/com/isuwang/dapeng/remoting/netty/SoaClient.java
``````

proposal

Most helpful comment

UP,,,I was looking forward to a netty trace support also :))

All 4 comments

UP,,,I was looking forward to a netty trace support also :))

Pinpoint supports Jetty which using Netty. The key point is that Netty is a transport lib, you can not find a common trace start entry in it, and for tcp and udp there are no common way to insert the span info into the packet to continue the trace too.

What I mean is that there could not be a common plugin for netty but you could write a plugin for your app in a level above netty.

hello,I want to monitor the trace of netty progresses;how can I do for it!

Was this page helpful?
0 / 5 - 0 ratings