Search in sources :

Example 6 with Span

use of io.opentracing.Span in project jaeger-client-java by jaegertracing.

the class JaegerThriftSpanConverterTest method testConvertSpan.

@Test
public void testConvertSpan() {
    Map<String, Object> fields = new HashMap<String, Object>();
    fields.put("k", "v");
    Span span = tracer.buildSpan("operation-name").startManual();
    span = span.log(1, fields);
    span = span.setBaggageItem("foo", "bar");
    com.uber.jaeger.thriftjava.Span thriftSpan = JaegerThriftSpanConverter.convertSpan((com.uber.jaeger.Span) span);
    assertEquals("operation-name", thriftSpan.getOperationName());
    assertEquals(2, thriftSpan.getLogs().size());
    Log thriftLog = thriftSpan.getLogs().get(0);
    assertEquals(1, thriftLog.getTimestamp());
    assertEquals(1, thriftLog.getFields().size());
    Tag thriftTag = thriftLog.getFields().get(0);
    assertEquals("k", thriftTag.getKey());
    assertEquals("v", thriftTag.getVStr());
    thriftLog = thriftSpan.getLogs().get(1);
    assertEquals(3, thriftLog.getFields().size());
    thriftTag = thriftLog.getFields().get(0);
    assertEquals("event", thriftTag.getKey());
    assertEquals("baggage", thriftTag.getVStr());
    thriftTag = thriftLog.getFields().get(1);
    assertEquals("value", thriftTag.getKey());
    assertEquals("bar", thriftTag.getVStr());
    thriftTag = thriftLog.getFields().get(2);
    assertEquals("key", thriftTag.getKey());
    assertEquals("foo", thriftTag.getVStr());
}
Also used : HashMap(java.util.HashMap) Log(com.uber.jaeger.thriftjava.Log) Tag(com.uber.jaeger.thriftjava.Tag) Span(io.opentracing.Span) Test(org.junit.Test)

Example 7 with Span

use of io.opentracing.Span in project jaeger-client-java by jaegertracing.

the class JaegerThriftSpanConverterTest method testConvertSpanTwoReferencesChildOf.

@Test
public void testConvertSpanTwoReferencesChildOf() {
    Span parent = tracer.buildSpan("foo").startManual();
    Span parent2 = tracer.buildSpan("foo").startManual();
    Span child = tracer.buildSpan("foo").asChildOf(parent).asChildOf(parent2).startManual();
    com.uber.jaeger.thriftjava.Span span = JaegerThriftSpanConverter.convertSpan((com.uber.jaeger.Span) child);
    assertEquals(0, span.getParentSpanId());
    assertEquals(2, span.getReferences().size());
    assertEquals(buildReference((SpanContext) parent.context(), References.CHILD_OF), span.getReferences().get(0));
    assertEquals(buildReference((SpanContext) parent2.context(), References.CHILD_OF), span.getReferences().get(1));
}
Also used : SpanContext(com.uber.jaeger.SpanContext) Span(io.opentracing.Span) Test(org.junit.Test)

Example 8 with Span

use of io.opentracing.Span in project ballerina by ballerina-lang.

the class OpenTracerManager method inject.

@Override
public Map<String, String> inject(Map<String, ?> activeSpanMap, String serviceName) {
    Map<String, String> carrierMap = new HashMap<>();
    for (Map.Entry<String, ?> activeSpanEntry : activeSpanMap.entrySet()) {
        Map<String, Tracer> tracers = tracerStore.getTracers(serviceName);
        Tracer tracer = tracers.get(activeSpanEntry.getKey());
        if (tracer != null) {
            Span span = (Span) activeSpanEntry.getValue();
            if (span != null) {
                tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new RequestInjector(carrierMap));
            }
        }
    }
    return carrierMap;
}
Also used : HashMap(java.util.HashMap) Tracer(io.opentracing.Tracer) Map(java.util.Map) HashMap(java.util.HashMap) Span(io.opentracing.Span)

Example 9 with Span

use of io.opentracing.Span in project ballerina by ballerina-lang.

the class OpenTracerManager method log.

@Override
public void log(List<?> spans, Map<String, ?> fields) {
    for (Object spanObj : spans) {
        Span span = (Span) spanObj;
        span.log(fields);
    }
}
Also used : Span(io.opentracing.Span)

Example 10 with Span

use of io.opentracing.Span in project ballerina by ballerina-lang.

the class OpenTracerManager method finishSpan.

@Override
public void finishSpan(List<?> spans) {
    for (Object spanObj : spans) {
        Span span = (Span) spanObj;
        span.finish();
    }
}
Also used : Span(io.opentracing.Span)

Aggregations

Span (io.opentracing.Span)368 Future (io.vertx.core.Future)182 HttpURLConnection (java.net.HttpURLConnection)174 Tracer (io.opentracing.Tracer)123 JsonObject (io.vertx.core.json.JsonObject)119 ClientErrorException (org.eclipse.hono.client.ClientErrorException)117 Map (java.util.Map)115 SpanContext (io.opentracing.SpanContext)114 Objects (java.util.Objects)109 List (java.util.List)104 TracingHelper (org.eclipse.hono.tracing.TracingHelper)104 Optional (java.util.Optional)102 Promise (io.vertx.core.Promise)98 Test (org.junit.jupiter.api.Test)96 MessageHelper (org.eclipse.hono.util.MessageHelper)89 Vertx (io.vertx.core.Vertx)84 Constants (org.eclipse.hono.util.Constants)82 ServerErrorException (org.eclipse.hono.client.ServerErrorException)80 Truth.assertThat (com.google.common.truth.Truth.assertThat)79 Mockito.mock (org.mockito.Mockito.mock)79