Fork me on GitHub

Pinpoint 更改agentid 和 agent name 长度限制(Pinpoint系列二)

本文基于 Pinpoint 2.1.0 版本

本文的内容为了更改 ID 和 Name 长度限制,因为有使用容器或者是服务名称确实比较长,所以根据业务场景,我们需要更改源码来实现这个。

具体更改,参考 https://github.com/pinpoint-apm/pinpoint/pull/6015/commits/29ab391de758336900256ef0ce24d806e3a1eab5。

更改的位置

bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/IdValidator.java

   private final BootLogger logger = BootLogger.getLogger(IdValidator.class.getName());

    private final Properties property;
    # private static final int MAX_ID_LENGTH = 24;   
    private static final int MAX_ID_LENGTH = 48;

    public IdValidator() {
        this(System.getProperties());

commons-server/src/main/java/com/navercorp/pinpoint/common/server/util/RowKeyUtils.java

       if (fixedBytes == null) {
            throw new NullPointerException("fixedBytes must not null");
        }
       # if (fixedBytes.length > maxFixedLength) {
        if (fixedBytes.length > 48) {
            throw new IndexOutOfBoundsException("fixedBytes.length too big. length:" + fixedBytes.length);
        }
        byte[] rowKey = new byte[maxFixedLength + LONG_BYTE_LENGTH];

commons/src/main/java/com/navercorp/pinpoint/common/PinpointConstants.java

public final class PinpointConstants {

   # public static final int APPLICATION_NAME_MAX_LEN = 24;
    public static final int APPLICATION_NAME_MAX_LEN = 48;

   # public static final int AGENT_NAME_MAX_LEN = 24;
    public static final int AGENT_NAME_MAX_LEN = 48;

}

上面所有注释的位置,都是源代码,下面的是我更改后的。我这边更改过后的长度为 48。更改完之后,我们重新编译打包即可。

注意

agent collectorweb 都要使用编译后的包。 具体编译操作见我们的 编译环境搭建。

posted @ 2020-11-24 11:22  自由早晚乱余生  阅读(1816)  评论(0编辑  收藏  举报