Skip to content

Commit 2857292

Browse files
committed
Feedback
1 parent a189db9 commit 2857292

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/TracingInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Response intercept(Chain chain) throws IOException {
4444
Response response;
4545
try (Scope ignored = context.makeCurrent()) {
4646
response = chain.proceed(request);
47-
} catch (Exception t) {
47+
} catch (Throwable t) {
4848
instrumenter.end(context, chain, null, t);
4949
throw t;
5050
}

instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/WebMvcTelemetryProducingFilter.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,21 @@ public void doFilterInternal(
6060
}
6161

6262
Context context = instrumenter.start(parentContext, request);
63-
if (httpRouteSupport.hasMappings()) {
64-
HttpServerRoute.update(context, CONTROLLER, httpRouteSupport::getHttpRoute, request);
65-
}
6663
AsyncAwareHttpServletRequest asyncAwareRequest =
6764
new AsyncAwareHttpServletRequest(request, response, context);
68-
65+
Throwable error = null;
6966
try (Scope ignored = context.makeCurrent()) {
7067
filterChain.doFilter(asyncAwareRequest, response);
7168
} catch (Throwable t) {
72-
instrumenter.end(context, request, response, t);
69+
error = t;
7370
throw t;
74-
}
75-
if (asyncAwareRequest.isNotAsync()) {
76-
instrumenter.end(context, request, response, null);
71+
} finally {
72+
if (httpRouteSupport.hasMappings()) {
73+
HttpServerRoute.update(context, CONTROLLER, httpRouteSupport::getHttpRoute, request);
74+
}
75+
if (error != null || asyncAwareRequest.isNotAsync()) {
76+
instrumenter.end(context, request, response, error);
77+
}
7778
}
7879
}
7980

instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/WebMvcTelemetryProducingFilter.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,21 @@ public void doFilterInternal(
6060
}
6161

6262
Context context = instrumenter.start(parentContext, request);
63-
if (httpRouteSupport.hasMappings()) {
64-
HttpServerRoute.update(context, CONTROLLER, httpRouteSupport::getHttpRoute, request);
65-
}
6663
AsyncAwareHttpServletRequest asyncAwareRequest =
6764
new AsyncAwareHttpServletRequest(request, response, context);
68-
65+
Throwable error = null;
6966
try (Scope ignored = context.makeCurrent()) {
7067
filterChain.doFilter(asyncAwareRequest, response);
7168
} catch (Throwable t) {
72-
instrumenter.end(context, request, response, t);
69+
error = t;
7370
throw t;
74-
}
75-
if (asyncAwareRequest.isNotAsync()) {
76-
instrumenter.end(context, request, response, null);
71+
} finally {
72+
if (httpRouteSupport.hasMappings()) {
73+
HttpServerRoute.update(context, CONTROLLER, httpRouteSupport::getHttpRoute, request);
74+
}
75+
if (error != null || asyncAwareRequest.isNotAsync()) {
76+
instrumenter.end(context, request, response, error);
77+
}
7778
}
7879
}
7980

0 commit comments

Comments
 (0)