diff --git a/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java b/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java index 8e49bc0b..77cec83e 100644 --- a/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java +++ b/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/apachehttpclient/v4_0/ApacheHttpClientUtils.java @@ -19,6 +19,7 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.Span; import io.opentelemetry.javaagent.instrumentation.hypertrace.apachehttpclient.v4_0.ApacheHttpClientObjectRegistry.SpanAndAttributeKey; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -113,7 +114,10 @@ public static void traceEntity( && contentEncoding.getValue().toLowerCase().contains("gzip"); if (entity.isRepeatable()) { try { - InputStream contentStream = entity.getContent(); + BoundedByteArrayOutputStream byteArrayOutputStream = + BoundedBuffersFactory.createStream(charset); + entity.writeTo(byteArrayOutputStream); + InputStream contentStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); if (isGzipEncoded) { try { contentStream = new GZIPInputStream(contentStream);