io.opentracing.contrib.concurrent.TracedExecutorService Java Examples

The following examples show how to use io.opentracing.contrib.concurrent.TracedExecutorService. 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: DefaultRiptideRegistrar.java    From riptide with MIT License 6 votes vote down vote up
private String registerExecutor(final String id, final Client client) {
    final String executorId = registry.registerIfAbsent(id, ExecutorService.class, () ->
            genericBeanDefinition(ThreadPoolFactory.class)
                    .addConstructorArgValue(id)
                    .addConstructorArgValue(client.getThreads())
                    .setFactoryMethod("create")
                    .setDestroyMethodName("shutdown"));

    if (client.getMetrics().getEnabled()) {
        registry.registerIfAbsent(id, ThreadPoolMetrics.class, () ->
                genericBeanDefinition(ThreadPoolMetrics.class)
                        .addConstructorArgReference(executorId)
                        .addConstructorArgValue("http.client.threads")
                        .addConstructorArgValue(ImmutableList.of(clientId(id))));
    }

    if (client.getTracing().getEnabled()) {
        return registry.registerIfAbsent(id, TracedExecutorService.class, () ->
                genericBeanDefinition(TracedExecutorService.class)
                        .addConstructorArgReference(executorId)
                        .addConstructorArgValue(TRACER_REF));
    }

    return executorId;
}
 
Example #2
Source File: TracingInterceptor.java    From java-okhttp with Apache License 2.0 5 votes vote down vote up
public static OkHttpClient addTracing(OkHttpClient.Builder builder,
                                      Tracer tracer, List<OkHttpClientSpanDecorator> decorators) {
    TracingInterceptor tracingInterceptor = new TracingInterceptor(tracer, decorators);
    builder.interceptors().add(0, tracingInterceptor);
    builder.networkInterceptors().add(0, tracingInterceptor);
    builder.dispatcher(new Dispatcher(new TracedExecutorService(Executors.newFixedThreadPool(10), tracer)));
    return builder.build();
}
 
Example #3
Source File: RestEasyClientITest.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Override
protected Client getClient() {
    return new ResteasyClientBuilder()
        /**
         * To avoid  RESTEASY004655 "connection is still allocated" in {@link #testAsyncMultipleRequests()}
         */
        .connectionPoolSize(150)
        .executorService(new TracedExecutorService(Executors.newFixedThreadPool(8), mockTracer))
        .build();
}
 
Example #4
Source File: JerseyClientITest.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Override
protected Client getClient() {
    return ClientBuilder.newBuilder()
        .register(new DelegateExecutorServiceProvider(
            new TracedExecutorService(Executors.newFixedThreadPool(8), mockTracer)))
        .build();
}
 
Example #5
Source File: ResteasyClientTracingRegistrarProvider.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public ClientBuilder configure(ClientBuilder clientBuilder, ExecutorService executorService) {
  ResteasyClientBuilder resteasyClientBuilder = (ResteasyClientBuilder)clientBuilder;
  Tracer tracer = CDI.current().select(Tracer.class).get();
  return resteasyClientBuilder.executorService(new TracedExecutorService(executorService, tracer))
    .register(new Builder(tracer)
        .withTraceSerialization(false)
        .build());
}
 
Example #6
Source File: ManualConfiguration.java    From riptide with MIT License 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public ExecutorService executor(final Tracer tracer) {
    return new TracedExecutorService(
            ThreadPoolExecutors.builder()
                .withoutQueue()
                .elasticSize(1, 20)
                .keepAlive(1, MINUTES)
                .threadFactory(new CustomizableThreadFactory("http-example-"))
                .build(),
            tracer);
}
 
Example #7
Source File: ResteasyClientTracingRegistrarProvider.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public ClientBuilder configure(ClientBuilder clientBuilder, ExecutorService executorService) {
    ResteasyClientBuilder resteasyClientBuilder = (ResteasyClientBuilder) clientBuilder;
    Tracer tracer = CDI.current().select(Tracer.class).get();
    return resteasyClientBuilder.executorService(new TracedExecutorService(executorService, tracer))
            .register(new SmallRyeClientTracingFeature(tracer));
}
 
Example #8
Source File: TracedExecutorServiceWrapper.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ExecutorService wrap(ExecutorService executor, String name, String... tags) {
  return new TracedExecutorService(executor, tracer);
}