use of io.jaegertracing.Configuration in project hono by eclipse.
the class KafkaHeadersInjectExtractAdapterTest method testJaegerTracerCanUseAdapter.
/**
* Verifies that the Jaeger tracer implementation can successfully use the adapters to inject and extract
* a SpanContext.
*/
@Test
public void testJaegerTracerCanUseAdapter() {
final Configuration config = new Configuration("test");
final Tracer tracer = config.getTracer();
final Span span = tracer.buildSpan("do").start();
final List<KafkaHeader> headers = new ArrayList<>();
final KafkaHeadersInjectAdapter injectAdapter = new KafkaHeadersInjectAdapter(headers);
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, injectAdapter);
final SpanContext context = tracer.extract(Format.Builtin.TEXT_MAP, new KafkaHeadersExtractAdapter(headers));
assertThat(context.toSpanId()).isEqualTo(span.context().toSpanId());
}
use of io.jaegertracing.Configuration 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.jaegertracing.Configuration 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.jaegertracing.Configuration in project jaeger-client-java by jaegertracing.
the class VersionTest method testVersionGet.
@Test
public void testVersionGet() {
assertEquals("Version should be the same as the properties file", JaegerTracer.getVersionFromProperties(), Version.get());
assertNotEquals("The version from the tracer should not be the same string as Version.get()", new Configuration("testVersionGet").getTracer().getVersion(), Version.get());
}
use of io.jaegertracing.Configuration in project jaeger-client-java by jaegertracing.
the class MicrometerTest method testExposedMetrics.
@Test
public void testExposedMetrics() {
Configuration configuration = new Configuration("exposedmetrics");
final JaegerTracer tracer = configuration.getTracerBuilder().withMetrics(metrics).build();
// This is a gauge, so it needs to be non-zero to come back from prometheus
metrics.reporterQueueLength.update(1);
List<Meter> meters = new ArrayList<>(prometheusRegistry.getMeters());
Map<String, Long> metricCounts = meters.stream().collect(groupingBy(m -> m.getId().getName(), counting()));
assertEquals("Wrong number of metrics collected", expectedMetricCounts.size(), metricCounts.keySet().size());
for (String name : metricCounts.keySet()) {
assertTrue("Unexpected metric " + name, expectedMetricCounts.containsKey(name));
}
for (String metricName : expectedMetricCounts.keySet()) {
assertTrue("Did not find metric " + metricName, metricCounts.containsKey(metricName));
assertEquals("Wrong count for " + metricName, expectedMetricCounts.get(metricName), metricCounts.get(metricName));
}
tracer.close();
}
Aggregations