use of io.opentracing.contrib.jaxrs2.server.ServerTracingDynamicFeature in project wildfly by wildfly.
the class TracerDynamicFeature method configure.
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
if (config == null) {
config = ConfigProvider.getConfig();
}
Optional<String> skipPattern = config.getOptionalValue("mp.opentracing.server.skip-pattern", String.class);
Optional<String> operationNameProvider = config.getOptionalValue("mp.opentracing.server.operation-name-provider", String.class);
Tracer tracer;
Object tracerObject = servletContext.getAttribute(SMALLRYE_OPENTRACING_TRACER);
if (tracerObject instanceof Tracer) {
tracer = (Tracer) tracerObject;
} else {
// should never happen, but if it does, there's something really wrong
// we log a warn-level message here then
TracingLogger.ROOT_LOGGER.noTracerAvailable();
return;
}
ServerTracingDynamicFeature.Builder builder = new ServerTracingDynamicFeature.Builder(tracer).withOperationNameProvider(ClassNameOperationName.newBuilder()).withTraceSerialization(false);
if (skipPattern.isPresent()) {
builder.withSkipPattern(skipPattern.get());
}
if (operationNameProvider.isPresent()) {
if ("http-path".equalsIgnoreCase(operationNameProvider.get())) {
builder.withOperationNameProvider(OperationNameProvider.WildcardOperationName.newBuilder());
} else if (!"class-method".equalsIgnoreCase(operationNameProvider.get())) {
TracingLogger.ROOT_LOGGER.wrongOperationNameProvider();
}
}
ServerTracingDynamicFeature delegate = builder.build();
delegate.configure(resourceInfo, context);
}
Aggregations