本文基於 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
和 collector
和 web
都要使用編譯後的包。 具體編譯操作見我們的 編譯環境搭建。