Search in sources :

Example 11 with Configuration

use of io.jaegertracing.Configuration in project hono by eclipse.

the class MessageAnnotationsInjectExtractAdapterTest method testJaegerTracerCanUseAdapter.

/**
 * Verifies that the Jaeger tracer implementation can successfully use the adapter 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 Message message = ProtonHelper.message();
    final MessageAnnotationsInjectAdapter injectAdapter = new MessageAnnotationsInjectAdapter(message, propertiesMapName);
    tracer.inject(span.context(), Format.Builtin.TEXT_MAP, injectAdapter);
    final SpanContext context = tracer.extract(Format.Builtin.TEXT_MAP, new MessageAnnotationsExtractAdapter(message, propertiesMapName));
    assertThat(context.toSpanId()).isEqualTo(span.context().toSpanId());
}
Also used : SpanContext(io.opentracing.SpanContext) Configuration(io.jaegertracing.Configuration) Message(org.apache.qpid.proton.message.Message) Tracer(io.opentracing.Tracer) Span(io.opentracing.Span) Test(org.junit.jupiter.api.Test)

Example 12 with Configuration

use of io.jaegertracing.Configuration in project hono by eclipse.

the class MultiMapInjectExtractAdapterTest method testJaegerTracerCanUseAdapter.

/**
 * Verifies that the Jaeger tracer implementation can successfully use the adapter 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 MultiMap multiMap = MultiMap.caseInsensitiveMultiMap();
    final MultiMapInjectAdapter injectAdapter = new MultiMapInjectAdapter(multiMap);
    tracer.inject(span.context(), Format.Builtin.TEXT_MAP, injectAdapter);
    final SpanContext context = tracer.extract(Format.Builtin.TEXT_MAP, new MultiMapExtractAdapter(multiMap));
    assertThat(context.toSpanId()).isEqualTo(span.context().toSpanId());
}
Also used : MultiMap(io.vertx.core.MultiMap) SpanContext(io.opentracing.SpanContext) Configuration(io.jaegertracing.Configuration) Tracer(io.opentracing.Tracer) Span(io.opentracing.Span) Test(org.junit.jupiter.api.Test)

Example 13 with Configuration

use of io.jaegertracing.Configuration in project hono by eclipse.

the class JsonObjectInjectExtractAdapterTest method testJaegerTracerCanUseAdapter.

/**
 * Verifies that the Jaeger tracer implementation can successfully use the adapter 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 JsonObject jsonObject = new JsonObject();
    final JsonObjectInjectAdapter injectAdapter = new JsonObjectInjectAdapter(jsonObject);
    tracer.inject(span.context(), Format.Builtin.TEXT_MAP, injectAdapter);
    final SpanContext context = tracer.extract(Format.Builtin.TEXT_MAP, new JsonObjectExtractAdapter(jsonObject));
    assertThat(context.toSpanId()).isEqualTo(span.context().toSpanId());
}
Also used : SpanContext(io.opentracing.SpanContext) Configuration(io.jaegertracing.Configuration) Tracer(io.opentracing.Tracer) JsonObject(io.vertx.core.json.JsonObject) Span(io.opentracing.Span) Test(org.junit.jupiter.api.Test)

Example 14 with Configuration

use of io.jaegertracing.Configuration in project wildfly by wildfly.

the class JaegerTracerConfiguration method createConfiguration.

/**
 * For testing purpose only.
 * @param serviceName
 * @return the jaeger tracer configuration.
 */
Configuration createConfiguration(String serviceName) {
    Configuration.SenderConfiguration senderConfiguration = reporterConfig.getSenderConfiguration();
    OutboundSocketBinding outboundSocketBinding = outboundSocketBindingSupplier.get();
    if (outboundSocketBinding != null) {
        senderConfiguration.withAgentHost(outboundSocketBinding.getUnresolvedDestinationAddress()).withAgentPort(outboundSocketBinding.getDestinationPort());
    }
    return new Configuration(serviceName).withCodec(codecConfig).withReporter(reporterConfig).withSampler(samplerConfig).withTraceId128Bit(traceId128Bit).withTracerTags(tracerTags);
}
Also used : CodecConfiguration(io.jaegertracing.Configuration.CodecConfiguration) ReporterConfiguration(io.jaegertracing.Configuration.ReporterConfiguration) TracerConfiguration(org.wildfly.microprofile.opentracing.smallrye.TracerConfiguration) Configuration(io.jaegertracing.Configuration) SamplerConfiguration(io.jaegertracing.Configuration.SamplerConfiguration) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding)

Example 15 with Configuration

use of io.jaegertracing.Configuration in project wildfly by wildfly.

the class JaegerTracerConfigurationTest method testModelResolution.

@Test
public void testModelResolution() throws OperationFailedException {
    ModelNode operation = Operations.createAddOperation(PathAddress.pathAddress("subsystem", "microprofile-opentracing-smallrye").append("jaeger-tracer", "jaeger").toModelNode());
    operation.get("propagation").add("B3").add(new ValueExpression("${jaeger.propagation:JAEGER}"));
    operation.get("sampler-type").set(new ValueExpression("${jaeger.sampler.type:const}"));
    operation.get("sampler-param").set(new ValueExpression("${jaeger.sampler-param:0.8}"));
    operation.get("sampler-manager-host-port").set(new ValueExpression("${jaeger.sampler-manager-host-port:localhost:4321}"));
    operation.get("sender-endpoint").set(new ValueExpression("${jaeger.sender.endpoint:http://localhost:14268/api/traces}"));
    operation.get("sender-auth-token").set(new ValueExpression("${jaeger.sender.auth-token:myAuthToken}"));
    operation.get("sender-auth-user").set(new ValueExpression("${jaeger.sender.user:sender}"));
    operation.get("sender-auth-password").set(new ValueExpression("${jaeger.sender.password:senderPassword}"));
    operation.get("reporter-log-spans").set(new ValueExpression("${jaeger.reporter.log-spans:false}"));
    operation.get("reporter-flush-interval").set(new ValueExpression("${jaeger.reporter.flush-interval:5}"));
    operation.get("reporter-max-queue-size").set(new ValueExpression("${jaeger.reporter.max-queue-size:10}"));
    operation.get("tracer_id_128bit").set(new ValueExpression("${jaeger.tracer_id_128bit:true}"));
    operation.get("tags").add("test", "${jaeger.reporter.max-queue-sizesimple}");
    JaegerTracerConfiguration tracerConfiguration = new JaegerTracerConfiguration(ExpressionResolver.TEST_RESOLVER, "jaeger", operation, () -> null);
    Configuration config = tracerConfiguration.createConfiguration("myApplication.war");
    Assert.assertEquals(2, config.getCodec().getCodecs().size());
    Assert.assertEquals(1, config.getCodec().getBinaryCodecs().size());
    Assert.assertEquals(2, config.getCodec().getCodecs().get(Format.Builtin.HTTP_HEADERS).size());
    Assert.assertEquals(2, config.getCodec().getCodecs().get(Format.Builtin.TEXT_MAP).size());
    Assert.assertEquals(1, config.getCodec().getBinaryCodecs().get(Format.Builtin.BINARY).size());
    Assert.assertEquals("const", config.getSampler().getType());
    Assert.assertEquals(0.8d, config.getSampler().getParam().doubleValue(), 0.01);
    Assert.assertEquals("localhost:4321", config.getSampler().getManagerHostPort());
    Assert.assertEquals("http://localhost:14268/api/traces", config.getReporter().getSenderConfiguration().getEndpoint());
    Assert.assertEquals("myAuthToken", config.getReporter().getSenderConfiguration().getAuthToken());
    Assert.assertEquals("sender", config.getReporter().getSenderConfiguration().getAuthUsername());
    Assert.assertEquals("senderPassword", config.getReporter().getSenderConfiguration().getAuthPassword());
    Assert.assertEquals(false, config.getReporter().getLogSpans());
    Assert.assertEquals(5, config.getReporter().getFlushIntervalMs().intValue());
    Assert.assertEquals(10, config.getReporter().getMaxQueueSize().intValue());
}
Also used : Configuration(io.jaegertracing.Configuration) ValueExpression(org.jboss.dmr.ValueExpression) ModelNode(org.jboss.dmr.ModelNode) 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