Skip to content

Commit

Permalink
Merge pull request #37218 from cescoffier/fix-otel-tracing-of-managem…
Browse files Browse the repository at this point in the history
…ent-interface

Fix OpenTelemetry trace exclusion of endpoints served from the management interface
  • Loading branch information
cescoffier authored Nov 21, 2023
2 parents bb0299d + 1c55119 commit 6956777
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.opentelemetry.deployment.tracing;

import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -118,7 +119,21 @@ void dropNames(
// Drop framework paths
List<String> nonApplicationUris = new ArrayList<>();
frameworkEndpoints.ifPresent(
frameworkEndpointsBuildItem -> nonApplicationUris.addAll(frameworkEndpointsBuildItem.getEndpoints()));
frameworkEndpointsBuildItem -> {
for (String endpoint : frameworkEndpointsBuildItem.getEndpoints()) {
// Management routes are using full urls -> Extract the path.
if (endpoint.startsWith("http://") || endpoint.startsWith("https://")) {
try {
nonApplicationUris.add(new URL(endpoint).getPath());
} catch (Exception ignored) { // Not an URL
nonApplicationUris.add(endpoint);
}
} else {
nonApplicationUris.add(endpoint);
}
}
});

dropNonApplicationUris.produce(new DropNonApplicationUrisBuildItem(nonApplicationUris));

// Drop Static Resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,24 @@ FrameworkEndpointsBuildItem frameworkEndpoints(NonApplicationRootPathBuildItem n
for (RouteBuildItem route : routes) {
if (FRAMEWORK_ROUTE.equals(route.getRouteType())) {
if (route.getConfiguredPathInfo() != null) {
frameworkEndpoints.add(route.getConfiguredPathInfo().getEndpointPath(nonApplicationRootPath,
managementInterfaceBuildTimeConfig, launchModeBuildItem));
String endpointPath = route.getConfiguredPathInfo().getEndpointPath(nonApplicationRootPath,
managementInterfaceBuildTimeConfig, launchModeBuildItem);
frameworkEndpoints.add(endpointPath);
continue;
}
if (route.getRouteFunction() != null && route.getRouteFunction() instanceof BasicRoute) {
BasicRoute basicRoute = (BasicRoute) route.getRouteFunction();
if (basicRoute.getPath() != null) {
// Calling TemplateHtmlBuilder does not see very correct here, but it is the underlying API for ConfiguredPathInfo
frameworkEndpoints
.add(adjustRoot(nonApplicationRootPath.getNonApplicationRootPath(), basicRoute.getPath()));
if (basicRoute.getPath().startsWith(nonApplicationRootPath.getNonApplicationRootPath())) {
// Do not repeat the non application root path.
frameworkEndpoints.add(basicRoute.getPath());
} else {
// Calling TemplateHtmlBuilder does not see very correct here, but it is the underlying API for ConfiguredPathInfo
String adjustRoot = adjustRoot(nonApplicationRootPath.getNonApplicationRootPath(),
basicRoute.getPath());
frameworkEndpoints.add(adjustRoot);
}

}
}
}
Expand Down

0 comments on commit 6956777

Please sign in to comment.