Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metro: ignore UnsupportedOperationException when updating span name #10996

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void updateServerSpanName(Context context, MetroRequest metroRequest) {
httpServletRequestAdapterEntry.getValue();
if (httpServletRequestAdapter.canHandle(request)) {
String servletPath = httpServletRequestAdapter.getServletPath(request);
if (!servletPath.isEmpty()) {
if (servletPath != null && !servletPath.isEmpty()) {
String pathInfo = httpServletRequestAdapter.getPathInfo(request);
if (pathInfo != null) {
spanName = servletPath + "/" + spanName;
Expand Down Expand Up @@ -147,6 +147,11 @@ public String getPathInfo(Object httpServletRequest) {
private static String invokeSafely(MethodHandle methodHandle, Object httpServletRequest) {
try {
return (String) methodHandle.invoke(httpServletRequest);
} catch (UnsupportedOperationException e) {
// when request wrapper throws UnsupportedOperationException return null to skip adding
// servlet path to the span name
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/10986
return null;
} catch (RuntimeException | Error e) {
throw e;
} catch (Throwable t) {
Expand Down
Loading