use of io.opencensus.tags.TagContext in project instrumentation-java by census-instrumentation.
the class CorrelationContextFormatTest method inject_TooManyTags.
@Test
public void inject_TooManyTags() throws TagContextSerializationException {
Tag[] tags = new Tag[CorrelationContextFormat.MAX_NUMBER_OF_TAGS + 1];
for (int i = 0; i < tags.length; i++) {
tags[i] = Tag.create(TagKey.create("k" + i), TagValue.create("v" + i), METADATA_UNLIMITED_PROPAGATION);
}
TagContext tagContext = makeTagContext(tags);
Map<String, String> carrier = new HashMap<String, String>();
thrown.expect(TagContextSerializationException.class);
textFormat.inject(tagContext, carrier, setter);
}
use of io.opencensus.tags.TagContext in project instrumentation-java by census-instrumentation.
the class CorrelationContextFormatTest method inject_SizeTooLarge.
@Test
public void inject_SizeTooLarge() throws TagContextSerializationException {
Tag[] tags = new Tag[40];
for (int i = 0; i < tags.length; i++) {
tags[i] = Tag.create(TagKey.create(generateRandom(240)), TagValue.create(generateRandom(240)), METADATA_UNLIMITED_PROPAGATION);
}
TagContext tagContext = makeTagContext(tags);
Map<String, String> carrier = new HashMap<String, String>();
thrown.expect(TagContextSerializationException.class);
textFormat.inject(tagContext, carrier, setter);
}
use of io.opencensus.tags.TagContext in project instrumentation-java by census-instrumentation.
the class CorrelationContextFormatTest method extract_WithUnknownProperties.
@Test
public void extract_WithUnknownProperties() throws TagContextDeserializationException {
Map<String, String> carrier = Collections.singletonMap(CORRELATION_CONTEXT, "k1=v1;property1=p1;property2=p2,k2=v2");
Tag expected = Tag.create(K1, TagValue.create("v1"), METADATA_UNLIMITED_PROPAGATION);
TagContext tagContext = textFormat.extract(carrier, getter);
assertThat(TagsTestUtil.tagContextToList(tagContext)).containsExactly(expected, T2);
}
use of io.opencensus.tags.TagContext in project instrumentation-java by census-instrumentation.
the class CorrelationContextFormatTest method extract.
@Test
public void extract() throws TagContextDeserializationException {
Map<String, String> carrier = Collections.singletonMap(CORRELATION_CONTEXT, "k1=v1,k2=v2");
TagContext tagContext = textFormat.extract(carrier, getter);
assertThat(TagsTestUtil.tagContextToList(tagContext)).containsExactly(T1, T2);
}
use of io.opencensus.tags.TagContext in project instrumentation-java by census-instrumentation.
the class TagContextRoundtripTest method testRoundtripSerialization.
private void testRoundtripSerialization(TagContext expected) throws Exception {
byte[] bytes = serializer.toByteArray(expected);
TagContext actual = serializer.fromByteArray(bytes);
assertThat(actual).isEqualTo(expected);
}
Aggregations