use of io.opentracing.Tracer in project hono by eclipse.
the class CoapOptionInjectExtractAdapterTest method testJaegerTracerInjectsAndExtractsSpanContext.
/**
* Verifies that the Jaeger tracer implementation can successfully use the adapter to inject and extract
* a SpanContext.
*/
@Test
public void testJaegerTracerInjectsAndExtractsSpanContext() {
final Configuration config = new Configuration("test");
final Tracer tracer = config.getTracer();
final Span span = tracer.buildSpan("do").start();
final OptionSet optionSet = new OptionSet();
final CoapOptionInjectExtractAdapter injectAdapter = CoapOptionInjectExtractAdapter.forInjection(optionSet);
tracer.inject(span.context(), Format.Builtin.BINARY, injectAdapter);
final SpanContext context = CoapOptionInjectExtractAdapter.forExtraction(optionSet).map(carrier -> tracer.extract(Format.Builtin.BINARY, carrier)).orElse(null);
assertThat(context.toSpanId()).isEqualTo(span.context().toSpanId());
}
use of io.opentracing.Tracer in project hono by eclipse.
the class ProtonBasedCommandRouterClientTest method setUp.
/**
* Sets up the fixture.
*/
@BeforeEach
public void setUp() {
span = TracingMockSupport.mockSpan();
final Tracer tracer = TracingMockSupport.mockTracer(span);
final EventBus eventBus = mock(EventBus.class);
final Vertx vertx = mock(Vertx.class);
when(vertx.eventBus()).thenReturn(eventBus);
receiver = AmqpClientUnitTestHelper.mockProtonReceiver();
sender = AmqpClientUnitTestHelper.mockProtonSender();
final RequestResponseClientConfigProperties config = new RequestResponseClientConfigProperties();
// don't let requestTimeout timer be started
config.setRequestTimeout(0);
connection = AmqpClientUnitTestHelper.mockHonoConnection(vertx, config, tracer);
when(connection.isConnected(anyLong())).thenReturn(Future.succeededFuture());
when(connection.createReceiver(anyString(), any(ProtonQoS.class), any(ProtonMessageHandler.class), VertxMockSupport.anyHandler())).thenReturn(Future.succeededFuture(receiver));
when(connection.createSender(anyString(), any(ProtonQoS.class), VertxMockSupport.anyHandler())).thenReturn(Future.succeededFuture(sender));
client = new ProtonBasedCommandRouterClient(connection, SendMessageSampler.Factory.noop());
}
use of io.opentracing.Tracer in project hono by eclipse.
the class TracingMockSupport method mockTracer.
/**
* Creates a mocked OpenTracing Tracer that will use a given SpanBuilder.
*
* @param spanBuilder The object that the <em>buildSpan</em> method of the
* returned tracer should return.
* @return The tracer.
*/
public static Tracer mockTracer(final SpanBuilder spanBuilder) {
final Tracer tracer = mock(Tracer.class);
when(tracer.buildSpan(anyString())).thenReturn(spanBuilder);
return tracer;
}
use of io.opentracing.Tracer in project cxf by apache.
the class Client method main.
public static void main(final String[] args) throws Exception {
final Tracer tracer = new Configuration("tracer-client").withSampler(new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1)).withReporter(new ReporterConfiguration().withSender(new SenderConfiguration() {
@Override
public Sender getSender() {
return new Slf4jLogSender();
}
})).getTracer();
final OpenTracingClientProvider provider = new OpenTracingClientProvider(tracer);
final Response response = WebClient.create("http://localhost:9000/catalog", Arrays.asList(provider)).accept(MediaType.APPLICATION_JSON).get();
System.out.println(response.readEntity(String.class));
response.close();
}
use of io.opentracing.Tracer in project jaeger-client-java by jaegertracing.
the class EndToEndBehaviorResourceTest method setUp.
@Before
public void setUp() throws Exception {
reporter = new InMemoryReporter();
Tracer tracer = new JaegerTracer.Builder("crossdock-java").withReporter(reporter).withSampler(new ConstSampler(true)).build();
Map<String, Tracer> tracers = new HashMap<>();
tracers.put("const", tracer);
resource = new EndToEndBehaviorResource(new EndToEndBehavior(tracers));
}
Aggregations