use of io.jaegertracing.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 io.jaegertracing.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 io.jaegertracing.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;
}
}
use of io.jaegertracing.thriftjava.Tag in project instrumentation-java by census-instrumentation.
the class JaegerExporterHandler method attributesToTags.
private static List<Tag> attributesToTags(final Map<String, AttributeValue> attributes, @Nullable final Tag extraTag) {
final List<Tag> tags = Lists.newArrayListWithExpectedSize(attributes.size() + 1);
for (final Map.Entry<String, AttributeValue> entry : attributes.entrySet()) {
final Tag tag = entry.getValue().match(stringAttributeConverter, booleanAttributeConverter, longAttributeConverter, doubleAttributeConverter, defaultAttributeConverter);
tag.setKey(entry.getKey());
tags.add(tag);
}
if (extraTag != null) {
tags.add(extraTag);
}
return tags;
}
use of io.jaegertracing.thriftjava.Tag in project instrumentation-java by census-instrumentation.
the class JaegerExporterHandler method addStatusTags.
private static void addStatusTags(List<Tag> tags, @Nullable Status status) {
if (status == null) {
return;
}
Tag statusTag = new Tag(STATUS_CODE, TagType.LONG).setVLong(status.getCanonicalCode().value());
tags.add(statusTag);
if (status.getDescription() != null) {
tags.add(new Tag(STATUS_MESSAGE, TagType.STRING).setVStr(status.getDescription()));
}
}
Aggregations