use of com.uber.jaeger.thriftjava.Tag in project jaeger-client-java by jaegertracing.
the class JaegerThriftSpanConverter method buildLogs.
static List<Log> buildLogs(List<LogData> logs) {
List<Log> thriftLogs = new ArrayList<Log>();
if (logs != null) {
for (LogData logData : logs) {
Log thriftLog = new Log();
thriftLog.setTimestamp(logData.getTime());
if (logData.getFields() != null) {
thriftLog.setFields(buildTags(logData.getFields()));
} else {
List<Tag> tags = new ArrayList<Tag>();
if (logData.getMessage() != null) {
tags.add(buildTag("event", logData.getMessage()));
}
thriftLog.setFields(tags);
}
thriftLogs.add(thriftLog);
}
}
return thriftLogs;
}
use of com.uber.jaeger.thriftjava.Tag in project jaeger-client-java by jaegertracing.
the class JaegerThriftSpanConverter method buildTag.
static Tag buildTag(String tagKey, Object tagValue) {
Tag tag = new Tag();
tag.setKey(tagKey);
if (tagValue instanceof Integer || tagValue instanceof Short || tagValue instanceof Long) {
tag.setVType(TagType.LONG);
tag.setVLong(((Number) tagValue).longValue());
} else if (tagValue instanceof Double || tagValue instanceof Float) {
tag.setVType(TagType.DOUBLE);
tag.setVDouble(((Number) tagValue).doubleValue());
} else if (tagValue instanceof Boolean) {
tag.setVType(TagType.BOOL);
tag.setVBool((Boolean) tagValue);
} else {
buildStringTag(tag, tagValue);
}
return tag;
}
use of com.uber.jaeger.thriftjava.Tag 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 com.uber.jaeger.thriftjava.Tag in project jaeger-client-java by jaegertracing.
the class JaegerThriftSpanConverterTest method testBuildTag.
@Test
@UseDataProvider("dataProviderBuildTag")
public void testBuildTag(Object tagValue, TagType tagType, Object expected) {
Tag tag = JaegerThriftSpanConverter.buildTag("key", tagValue);
assertEquals(tagType, tag.getVType());
assertEquals("key", tag.getKey());
switch(tagType) {
case STRING:
default:
assertEquals(expected, tag.getVStr());
break;
case BOOL:
assertEquals(expected, tag.isVBool());
break;
case LONG:
assertEquals(expected, tag.getVLong());
break;
case DOUBLE:
assertEquals(expected, tag.getVDouble());
break;
case BINARY:
break;
}
}
Aggregations