in apm-sniffer/optional-plugins/netty-http-4.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/netty/http/utils/HttpDataCollectUtils.java [39:68]
public static void collectHttpRequestBody(HttpHeaders headers, ByteBuf content, AbstractSpan span) {
try {
if (headers == null || content == null || span == null) {
return;
}
if (Unpooled.EMPTY_BUFFER.equals(content)) {
return;
}
String contentTypeValue = headers.get(HttpHeaderNames.CONTENT_TYPE);
boolean needCollectHttpBody = false;
for (String contentType : NettyHttpPluginConfig.Plugin.NettyHttp.SUPPORTED_CONTENT_TYPES_PREFIX.split(",")) {
if (contentTypeValue.startsWith(contentType)) {
needCollectHttpBody = true;
break;
}
}
if (needCollectHttpBody) {
String bodyStr = content.toString(getCharsetFromContentType(
headers.get(HttpHeaderNames.CONTENT_TYPE)));
bodyStr = NettyHttpPluginConfig.Plugin.NettyHttp.FILTER_LENGTH_LIMIT > 0 ?
StringUtil.cut(bodyStr, NettyHttpPluginConfig.Plugin.NettyHttp.FILTER_LENGTH_LIMIT) : bodyStr;
Tags.HTTP.BODY.set(span, bodyStr);
}
} catch (Exception e) {
LOGGER.error("Fail to collect netty http request body", e);
}
}