io.opentracing.contrib.jaxrs2.client.ClientTracingFeature Java Examples

The following examples show how to use io.opentracing.contrib.jaxrs2.client.ClientTracingFeature. 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: 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 #2
Source File: AbstractClientTest.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultConfiguration() {
    MockTracer mockTracer = new MockTracer(new ThreadLocalScopeManager(), Propagator.TEXT_MAP);
    GlobalTracer.registerIfAbsent(mockTracer);

    Client client = ClientBuilder.newClient()
            .register(ClientTracingFeature.class);

    Response response = client.target(url("/hello"))
            .request()
            .get();
    response.close();
    assertNoActiveSpan();
    Assert.assertEquals(1, mockTracer.finishedSpans().size());
}
 
Example #3
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 #4
Source File: EndpointConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public EndpointConfig(@Value("${info.app.version:unspecified}") String applicationVersion,
        @Value("${environment.structuredevent.rest.enabled:false}") Boolean auditEnabled,
        List<ExceptionMapper<?>> exceptionMappers, ServerTracingDynamicFeature serverTracingDynamicFeature,
        ClientTracingFeature clientTracingFeature) {

    this.applicationVersion = applicationVersion;
    this.auditEnabled = auditEnabled;
    this.exceptionMappers = exceptionMappers;
    registerEndpoints();
    registerExceptionMappers();
    registerSwagger();
    register(serverTracingDynamicFeature);
    register(clientTracingFeature);
}
 
Example #5
Source File: TracingConfiguration.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public ClientTracingFeature clientTracingFeature() {
    ClientTracingFeature.Builder clientTracingFeatureBuilder = new ClientTracingFeature.Builder(tracer);
    clientTracingFeatureBuilder.withTraceSerialization(false);
    clientTracingFeatureBuilder.withDecorators(List.of(new SpanDecorator()));
    return clientTracingFeatureBuilder.build();
}
 
Example #6
Source File: JaxRsAgentIntercept.java    From java-specialagent with Apache License 2.0 4 votes vote down vote up
public static void enter(final Object thiz) {
  final ClientBuilder builder = (ClientBuilder)thiz;
  builder.register(ClientTracingFeature.class);
}
 
Example #7
Source File: ThreadLocalUserCrnWebTargetBuilder.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public ThreadLocalUserCrnWebTargetBuilder withTracer(ClientTracingFeature tracer) {
    this.tracer = tracer;
    return this;
}
 
Example #8
Source File: CloudbreakApiClientConfig.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public CloudbreakApiClientConfig(ApiClientRequestFilter apiClientRequestFilter, ClientTracingFeature clientTracingFeature) {
    this.apiClientRequestFilter = apiClientRequestFilter;
    this.clientTracingFeature = clientTracingFeature;
}
 
Example #9
Source File: EnvironmentApiClientConfig.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public EnvironmentApiClientConfig(ApiClientRequestFilter apiClientRequestFilter, ClientTracingFeature clientTracingFeature) {
    this.apiClientRequestFilter = apiClientRequestFilter;
    this.clientTracingFeature = clientTracingFeature;
}
 
Example #10
Source File: RedbeamsApiClientConfig.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public RedbeamsApiClientConfig(ApiClientRequestFilter apiClientRequestFilter, ClientTracingFeature clientTracingFeature) {
    this.apiClientRequestFilter = apiClientRequestFilter;
    this.clientTracingFeature = clientTracingFeature;
}