Skip to content

Commit a5443aa

Browse files
authoredFeb 26, 2025··
feat: fix servlet3.0 header capture (#415)
* fix servlet3.0 headeres capture * fix condition
1 parent c5b39b1 commit a5443aa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎instrumentation/servlet/servlet-3.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/servlet/v3_0/nowrapping/Servlet30AndFilterInstrumentation.java

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

184184
if (!request.isAsyncStarted()) {
185185
if (instrumentationConfig.httpHeaders().response()) {
186+
if (throwable == null && !httpResponse.isCommitted()) {
187+
httpResponse.flushBuffer();
188+
}
186189
for (String headerName : httpResponse.getHeaderNames()) {
187190
String headerValue = httpResponse.getHeader(headerName);
188191
currentSpan.setAttribute(
@@ -212,6 +215,7 @@ public static void exit(
212215
urlEncodedMapContextStore);
213216
}
214217
}
218+
} catch (IOException e) {
215219
} finally {
216220
Throwable tmp = throwable;
217221
while (tmp != null) { // loop in case our exception is nested (eg. springframework)

0 commit comments

Comments
 (0)
Please sign in to comment.