io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter Java Examples

The following examples show how to use io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter. 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: SmallRyeOpenTracingProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
void setupFilter(BuildProducer<ResteasyJaxrsProviderBuildItem> providers,
        BuildProducer<FilterBuildItem> filterProducer,
        BuildProducer<FeatureBuildItem> feature,
        Capabilities capabilities) {

    feature.produce(new FeatureBuildItem(Feature.SMALLRYE_OPENTRACING));

    providers.produce(new ResteasyJaxrsProviderBuildItem(QuarkusSmallRyeTracingDynamicFeature.class.getName()));

    if (capabilities.isPresent(Capability.SERVLET)) {
        FilterBuildItem filterInfo = FilterBuildItem.builder("tracingFilter", SpanFinishingFilter.class.getName())
                .setAsyncSupported(true)
                .addFilterUrlMapping("*", DispatcherType.FORWARD)
                .addFilterUrlMapping("*", DispatcherType.INCLUDE)
                .addFilterUrlMapping("*", DispatcherType.REQUEST)
                .addFilterUrlMapping("*", DispatcherType.ASYNC)
                .addFilterUrlMapping("*", DispatcherType.ERROR)
                .build();
        filterProducer.produce(filterInfo);
    } else {
        //otherwise we know we have RESTeasy on vert.x
        providers.produce(
                new ResteasyJaxrsProviderBuildItem(QuarkusSmallRyeTracingStandaloneVertxDynamicFeature.class.getName()));
    }
}
 
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: AbstractJettyTest.java    From java-jaxrs with Apache License 2.0 6 votes vote down vote up
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    ServerTracingDynamicFeature serverTracingFeature =
        new ServerTracingDynamicFeature.Builder(mockTracer)
            .withOperationNameProvider(HTTPMethodOperationName.newBuilder())
            .withDecorators(Collections.singletonList(ServerSpanDecorator.STANDARD_TAGS))
            .withSkipPattern("/health")
        .build();
    // TODO clarify dispatcher types
    context.addFilter(new FilterHolder(new SpanFinishingFilter()), "/*",
        EnumSet.of(
            DispatcherType.REQUEST,
            // TODO CXF does not call AsyncListener#onComplete() without this (it calls only onStartAsync)
            DispatcherType.ASYNC));

    context.setAttribute(CLIENT_ATTRIBUTE, client);
    context.setAttribute(TRACER_ATTRIBUTE, mockTracer);
    context.setAttribute(SERVER_TRACING_FEATURE, serverTracingFeature);
}
 
Example #4
Source File: AbstractWildcardOperationNameTest.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Override
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    ServerTracingDynamicFeature serverTracingBuilder =
        new ServerTracingDynamicFeature.Builder(mockTracer)
            .withOperationNameProvider(WildcardOperationName.newBuilder())
        .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, serverTracingBuilder);
}
 
Example #5
Source File: AbstractServerWithTraceNothingTest.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Override
protected void initTracing(ServletContextHandler context) {
    client.register(new ClientTracingFeature.Builder(mockTracer).build());

    ServerTracingDynamicFeature serverTracingBuilder =
            new ServerTracingDynamicFeature.Builder(mockTracer)
                    .withTraceNothing() // This should only trace @Traced annotations, per documentation!
                    .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, serverTracingBuilder);
}
 
Example #6
Source File: AbstractClassOperationNameTest.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Override
protected void initTracing(ServletContextHandler context) {
  client.register(new Builder(mockTracer).build());

  ServerTracingDynamicFeature serverTracingBuilder =
      new ServerTracingDynamicFeature.Builder(mockTracer)
          .withOperationNameProvider(ClassNameOperationName.newBuilder())
          .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, serverTracingBuilder);
}
 
Example #7
Source File: AbstractServerDefaultConfigurationTest.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Override
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    ServerTracingDynamicFeature serverTracingBuilder =
            new ServerTracingDynamicFeature.Builder(mockTracer)
                    .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, serverTracingBuilder);
}
 
Example #8
Source File: Configuration.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean spanFinishingFilter() {
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    filterRegistrationBean.setFilter(new SpanFinishingFilter());
    filterRegistrationBean.setAsyncSupported(true);
    filterRegistrationBean.setDispatcherTypes(DispatcherType.REQUEST);
    filterRegistrationBean.addUrlPatterns("*");
    return filterRegistrationBean;
}
 
Example #9
Source File: OpenTracingContextInitializer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
  ServletContext servletContext = servletContextEvent.getServletContext();
  Dynamic filterRegistration = servletContext
      .addFilter("tracingFilter", new SpanFinishingFilter());
  filterRegistration.setAsyncSupported(true);
  filterRegistration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");
}
 
Example #10
Source File: CommonFilterConfiguration.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterRegistrationBean spanFinishingFilter() {
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    filterRegistrationBean.setFilter(new SpanFinishingFilter());
    filterRegistrationBean.setAsyncSupported(true);
    filterRegistrationBean.setOrder(Integer.MIN_VALUE);
    filterRegistrationBean.setDispatcherTypes(DispatcherType.REQUEST);
    filterRegistrationBean.addUrlPatterns("*");
    return filterRegistrationBean;
}