From 48d697eb4504b50b9dcb844ed2d9d4ec10a94a10 Mon Sep 17 00:00:00 2001 From: SylvainJuge Date: Wed, 30 Jun 2021 13:39:04 +0200 Subject: [PATCH] avoid allocation for legacy servers (#1891) --- .../apm/agent/report/serialize/DslJsonSerializer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/DslJsonSerializer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/DslJsonSerializer.java index 16c24eaa5e..8115457b90 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/DslJsonSerializer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/DslJsonSerializer.java @@ -1184,7 +1184,12 @@ private void serializeUrl(final Url url) { writeField("port", port); } else { // serialize as a string for compatibility - writeField("port", Integer.toString(port)); + // doing it in low-level to avoid allocation + writeFieldName("port", jw); + jw.writeByte(QUOTE); + NumberConverter.serialize(port, jw); + jw.writeByte(QUOTE); + jw.writeByte(COMMA); } writeField("pathname", url.getPathname()); writeField("search", url.getSearch());