-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Undertow dependency from Opentracing
Fixes #5419
- Loading branch information
1 parent
f1fd426
commit 507ee79
Showing
6 changed files
with
127 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
.../deployment/src/test/java/io/quarkus/smallrye/opentracing/deployment/TracerRegistrar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
package io.quarkus.smallrye.opentracing.deployment; | ||
|
||
import javax.servlet.ServletContextEvent; | ||
import javax.servlet.ServletContextListener; | ||
import javax.servlet.annotation.WebListener; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
|
||
import io.opentracing.util.GlobalTracer; | ||
import io.quarkus.runtime.StartupEvent; | ||
|
||
@WebListener | ||
public class TracerRegistrar implements ServletContextListener { | ||
@ApplicationScoped | ||
public class TracerRegistrar { | ||
|
||
@Override | ||
public void contextInitialized(ServletContextEvent sce) { | ||
public void start(@Observes StartupEvent start) { | ||
GlobalTracer.register(TracingTest.mockTracer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...kus/smallrye/opentracing/runtime/QuarkusSmallRyeTracingStandaloneVertxDynamicFeature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package io.quarkus.smallrye.opentracing.runtime; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.enterprise.inject.spi.CDI; | ||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerRequestFilter; | ||
import javax.ws.rs.container.DynamicFeature; | ||
import javax.ws.rs.container.ResourceInfo; | ||
import javax.ws.rs.core.FeatureContext; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
import io.opentracing.Span; | ||
import io.opentracing.contrib.jaxrs2.internal.SpanWrapper; | ||
import io.opentracing.tag.Tags; | ||
import io.quarkus.vertx.http.runtime.CurrentVertxRequest; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
@Provider | ||
public class QuarkusSmallRyeTracingStandaloneVertxDynamicFeature implements DynamicFeature { | ||
|
||
@Override | ||
public void configure(ResourceInfo resourceInfo, FeatureContext context) { | ||
context.register(StandaloneFilter.class); | ||
} | ||
|
||
public static class StandaloneFilter implements ContainerRequestFilter { | ||
|
||
volatile CurrentVertxRequest currentVertxRequest; | ||
|
||
CurrentVertxRequest request() { | ||
if (currentVertxRequest == null) { | ||
currentVertxRequest = CDI.current().select(CurrentVertxRequest.class).get(); | ||
} | ||
return currentVertxRequest; | ||
} | ||
|
||
@Override | ||
public void filter(ContainerRequestContext requestContext) throws IOException { | ||
request().addRequestDoneListener(new CurrentVertxRequest.Listener() { | ||
@Override | ||
public void initialInvocationComplete(RoutingContext routingContext, boolean goingAsync) { | ||
SpanWrapper wrapper = routingContext.get(SpanWrapper.PROPERTY_NAME); | ||
if (wrapper != null) { | ||
wrapper.getScope().close(); | ||
} | ||
} | ||
|
||
@Override | ||
public void responseComplete(RoutingContext routingContext) { | ||
SpanWrapper wrapper = routingContext.get(SpanWrapper.PROPERTY_NAME); | ||
if (wrapper == null) { | ||
return; | ||
} | ||
|
||
Tags.HTTP_STATUS.set(wrapper.get(), routingContext.response().getStatusCode()); | ||
if (routingContext.failure() != null) { | ||
addExceptionLogs(wrapper.get(), routingContext.failure()); | ||
} | ||
wrapper.finish(); | ||
|
||
} | ||
}); | ||
|
||
} | ||
|
||
private static void addExceptionLogs(Span span, Throwable throwable) { | ||
Tags.ERROR.set(span, true); | ||
if (throwable != null) { | ||
Map<String, Object> errorLogs = new HashMap<>(2); | ||
errorLogs.put("event", Tags.ERROR.getKey()); | ||
errorLogs.put("error.object", throwable); | ||
span.log(errorLogs); | ||
} | ||
} | ||
} | ||
} |