Search in sources :

Example 1 with Configuration

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());
}
Also used : SpanContext(io.opentracing.SpanContext) Configuration(io.jaegertracing.Configuration) Tracer(io.opentracing.Tracer) ArrayList(java.util.ArrayList) Span(io.opentracing.Span) KafkaHeader(io.vertx.kafka.client.producer.KafkaHeader) Test(org.junit.jupiter.api.Test)

Example 2 with Configuration

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());
}
Also used : Test(org.junit.jupiter.api.Test) Tracer(io.opentracing.Tracer) Format(io.opentracing.propagation.Format) Configuration(io.jaegertracing.Configuration) Span(io.opentracing.Span) OptionSet(org.eclipse.californium.core.coap.OptionSet) Truth.assertThat(com.google.common.truth.Truth.assertThat) SpanContext(io.opentracing.SpanContext) SpanContext(io.opentracing.SpanContext) Configuration(io.jaegertracing.Configuration) Tracer(io.opentracing.Tracer) OptionSet(org.eclipse.californium.core.coap.OptionSet) Span(io.opentracing.Span) Test(org.junit.jupiter.api.Test)

Example 3 with Configuration

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();
}
Also used : Slf4jLogSender(demo.jaxrs.tracing.Slf4jLogSender) Sender(io.jaegertracing.spi.Sender) Response(javax.ws.rs.core.Response) SenderConfiguration(io.jaegertracing.Configuration.SenderConfiguration) ReporterConfiguration(io.jaegertracing.Configuration.ReporterConfiguration) Configuration(io.jaegertracing.Configuration) SamplerConfiguration(io.jaegertracing.Configuration.SamplerConfiguration) Tracer(io.opentracing.Tracer) OpenTracingClientProvider(org.apache.cxf.tracing.opentracing.jaxrs.OpenTracingClientProvider) SamplerConfiguration(io.jaegertracing.Configuration.SamplerConfiguration) Slf4jLogSender(demo.jaxrs.tracing.Slf4jLogSender) SenderConfiguration(io.jaegertracing.Configuration.SenderConfiguration) ReporterConfiguration(io.jaegertracing.Configuration.ReporterConfiguration)

Example 4 with Configuration

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());
}
Also used : Configuration(io.jaegertracing.Configuration) Test(org.junit.Test)

Example 5 with Configuration

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();
}
Also used : Metrics(io.jaegertracing.internal.metrics.Metrics) MethodSorters(org.junit.runners.MethodSorters) BeforeClass(org.junit.BeforeClass) Collectors.counting(java.util.stream.Collectors.counting) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) HashMap(java.util.HashMap) JaegerSpan(io.jaegertracing.internal.JaegerSpan) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) Map(java.util.Map) After(org.junit.After) Sampler(io.jaegertracing.spi.Sampler) IsEqual(org.hamcrest.core.IsEqual) Timer(io.jaegertracing.internal.metrics.Timer) Before(org.junit.Before) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Assert.assertTrue(org.junit.Assert.assertTrue) Meter(io.micrometer.core.instrument.Meter) Test(org.junit.Test) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) Configuration(io.jaegertracing.Configuration) FixMethodOrder(org.junit.FixMethodOrder) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Assert.assertEquals(org.junit.Assert.assertEquals) PrometheusConfig(io.micrometer.prometheus.PrometheusConfig) Configuration(io.jaegertracing.Configuration) Meter(io.micrometer.core.instrument.Meter) ArrayList(java.util.ArrayList) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Aggregations

Configuration (io.jaegertracing.Configuration)15 Tracer (io.opentracing.Tracer)7 Span (io.opentracing.Span)5 SpanContext (io.opentracing.SpanContext)5 Test (org.junit.Test)5 Test (org.junit.jupiter.api.Test)5 ReporterConfiguration (io.jaegertracing.Configuration.ReporterConfiguration)4 SamplerConfiguration (io.jaegertracing.Configuration.SamplerConfiguration)4 JaegerTracer (io.jaegertracing.internal.JaegerTracer)2 ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)2 Sampler (io.jaegertracing.spi.Sampler)2 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Slf4jLogSender (demo.jaxrs.tracing.Slf4jLogSender)1 CodecConfiguration (io.jaegertracing.Configuration.CodecConfiguration)1 SenderConfiguration (io.jaegertracing.Configuration.SenderConfiguration)1 JerseyServer (io.jaegertracing.crossdock.JerseyServer)1 EndToEndBehavior (io.jaegertracing.crossdock.resources.behavior.EndToEndBehavior)1