use of io.opencensus.tags.Tag in project instrumentation-java by census-instrumentation.
the class TagMapImplTest method testIterator.
@Test
public void testIterator() {
TagMapImpl tags = new TagMapImpl(ImmutableMap.of(K1, VM1, K2, VM2));
Iterator<Tag> i = tags.getIterator();
assertTrue(i.hasNext());
Tag tag1 = i.next();
assertTrue(i.hasNext());
Tag tag2 = i.next();
assertFalse(i.hasNext());
assertThat(Arrays.asList(tag1, tag2)).containsExactly(Tag.create(K1, V1), Tag.create(K2, V2));
thrown.expect(NoSuchElementException.class);
i.next();
}
use of io.opencensus.tags.Tag in project instrumentation-java by census-instrumentation.
the class CorrelationContextFormatTest method inject_SkipNonPropagatingTag.
@Test
public void inject_SkipNonPropagatingTag() throws TagContextSerializationException {
Map<String, String> carrier = new HashMap<String, String>();
Tag tag = Tag.create(K1, V1, METADATA_NO_PROPAGATION);
textFormat.inject(makeTagContext(tag), carrier, setter);
assertThat(carrier).containsExactly(CORRELATION_CONTEXT, "");
}
use of io.opencensus.tags.Tag in project instrumentation-java by census-instrumentation.
the class CorrelationContextFormatTest method roundTrip.
@Test
public void roundTrip() throws TagContextSerializationException, TagContextDeserializationException {
Tag[] tags = new Tag[40];
for (int i = 0; i < tags.length; i++) {
tags[i] = Tag.create(TagKey.create(generateRandom(10)), TagValue.create(generateRandom(10)), METADATA_UNLIMITED_PROPAGATION);
}
TagContext tagContext = makeTagContext(tags);
Map<String, String> carrier = new HashMap<String, String>();
textFormat.inject(tagContext, carrier, setter);
TagContext actual = textFormat.extract(carrier, getter);
assertThat(TagsTestUtil.tagContextToList(actual)).containsExactlyElementsIn(TagsTestUtil.tagContextToList(tagContext));
}
use of io.opencensus.tags.Tag in project instrumentation-java by census-instrumentation.
the class CorrelationContextFormatTest method extract_TrimSpaces.
@Test
public void extract_TrimSpaces() throws TagContextDeserializationException {
Map<String, String> carrier = Collections.singletonMap(CORRELATION_CONTEXT, "k1= v1, k2=v2 ");
Tag expected1 = Tag.create(K1, V1, METADATA_UNLIMITED_PROPAGATION);
Tag expected2 = Tag.create(K2, V2, METADATA_UNLIMITED_PROPAGATION);
TagContext tagContext = textFormat.extract(carrier, getter);
assertThat(TagsTestUtil.tagContextToList(tagContext)).containsExactly(expected1, expected2);
}
use of io.opencensus.tags.Tag in project instrumentation-java by census-instrumentation.
the class TaggerImplTest method currentBuilder_RemoveDuplicateTags.
@Test
public void currentBuilder_RemoveDuplicateTags() {
Tag tag1 = Tag.create(K1, V1);
Tag tag2 = Tag.create(K1, V2);
TagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2);
TagContextBuilder result = getResultOfCurrentBuilder(tagContextWithDuplicateTags);
assertThat(tagContextToList(result.build())).containsExactly(tag2);
}
Aggregations