Java Code Examples for io.opentracing.contrib.jaxrs2.server.ServerTracingDynamicFeature#Builder

The following examples show how to use io.opentracing.contrib.jaxrs2.server.ServerTracingDynamicFeature#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuarkusSmallRyeTracingDynamicFeature.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public QuarkusSmallRyeTracingDynamicFeature() {
    Config 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);

    ServerTracingDynamicFeature.Builder builder = new ServerTracingDynamicFeature.Builder(
            CDI.current().select(Tracer.class).get())
                    .withOperationNameProvider(OperationNameProvider.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())) {
            logger.warn("Provided operation name does not match http-path or class-method. Using default class-method.");
        }
    }
    this.delegate = builder.build();
}
 
Example 2
Source File: AbstractParentSpanResolutionTest.java    From java-jaxrs with Apache License 2.0 6 votes vote down vote up
@Override
protected void initTracing(ServletContextHandler context) {
    client.register(new ClientTracingFeature.Builder(mockTracer).build());

    ServerTracingDynamicFeature.Builder builder = new ServerTracingDynamicFeature.Builder(mockTracer);
    if (shouldUseParentSpan()) {
        builder = builder.withJoinExistingActiveSpan(true);
    }
    ServerTracingDynamicFeature serverTracingFeature = builder.build();

    context.addFilter(new FilterHolder(new SpanFinishingFilter()),
            "/*", EnumSet.of(DispatcherType.REQUEST));

    context.setAttribute(TRACER_ATTRIBUTE, mockTracer);
    context.setAttribute(CLIENT_ATTRIBUTE, client);
    context.setAttribute(SERVER_TRACING_FEATURE, serverTracingFeature);
}
 
Example 3
Source File: TracingConfiguration.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public ServerTracingDynamicFeature serverTracingDynamicFeature() {
    ServerTracingDynamicFeature.Builder serverTracingFeatureBuilder = new ServerTracingDynamicFeature.Builder(tracer);
    serverTracingFeatureBuilder.withTraceSerialization(false);
    serverTracingFeatureBuilder.withDecorators(List.of(new SpanDecorator()));
    return serverTracingFeatureBuilder.build();
}