Skip to content

Commit 974191e

Browse files
authored
feat: servlet 5.0 body capture fix (#411)
* flush to get all headers * spotless apply
1 parent 40c54bf commit 974191e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

instrumentation/servlet/servlet-5.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/servlet/v5_0/Servlet50AndFilterInstrumentation.java

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ public static void exit(
187187

188188
if (!request.isAsyncStarted()) {
189189
if (instrumentationConfig.httpHeaders().response()) {
190+
if (throwable == null && !httpResponse.isCommitted()) {
191+
httpResponse.flushBuffer();
192+
}
190193
for (String headerName : httpResponse.getHeaderNames()) {
191194
String headerValue = httpResponse.getHeader(headerName);
192195
currentSpan.setAttribute(
@@ -216,6 +219,7 @@ public static void exit(
216219
urlEncodedMapContextStore);
217220
}
218221
}
222+
} catch (IOException ignored) {
219223
} finally {
220224
Throwable tmp = throwable;
221225
while (tmp != null) { // loop in case our exception is nested (eg. springframework)

0 commit comments

Comments
 (0)