Search in sources :

Example 11 with Tag

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;
}
Also used : Tag(io.jaegertracing.thriftjava.Tag)

Example 12 with 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;
}
Also used : LogData(io.jaegertracing.internal.LogData) Log(io.jaegertracing.thriftjava.Log) ArrayList(java.util.ArrayList) Tag(io.jaegertracing.thriftjava.Tag)

Example 13 with Tag

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;
    }
}
Also used : Tag(io.jaegertracing.thriftjava.Tag) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 14 with Tag

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;
}
Also used : AttributeValue(io.opencensus.trace.AttributeValue) Tag(io.jaegertracing.thriftjava.Tag) Map(java.util.Map)

Example 15 with Tag

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()));
    }
}
Also used : Tag(io.jaegertracing.thriftjava.Tag)

Aggregations

Tag (io.jaegertracing.thriftjava.Tag)23 Test (org.junit.Test)14 Annotation (wavefront.report.Annotation)12 SpanSampler (com.wavefront.agent.sampler.SpanSampler)11 Batch (io.jaegertracing.thriftjava.Batch)11 Span (wavefront.report.Span)11 Process (io.jaegertracing.thriftjava.Process)10 Collector (io.jaegertracing.thriftjava.Collector)9 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)8 Log (io.jaegertracing.thriftjava.Log)8 SpanLog (wavefront.report.SpanLog)5 Span (io.jaegertracing.thriftjava.Span)3 SpanData (io.opencensus.trace.export.SpanData)3 ArrayList (java.util.ArrayList)3 DurationSampler (com.wavefront.sdk.entities.tracing.sampling.DurationSampler)2 SpanRef (io.jaegertracing.thriftjava.SpanRef)2 AttributeValue (io.opencensus.trace.AttributeValue)2 Map (java.util.Map)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1