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());
}
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));
}
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;
}
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);
}
}
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();
}
}
Aggregations