Search in sources :

Example 11 with TagContextBuilder

use of io.opencensus.tags.TagContextBuilder in project instrumentation-java by census-instrumentation.

the class TaggerImplTest method currentBuilder_TaggingReenabled.

@Test
public void currentBuilder_TaggingReenabled() {
    TagContext tags = new SimpleTagContext(TAG1);
    tagsComponent.setState(TaggingState.DISABLED);
    assertThat(getResultOfCurrentBuilder(tags)).isSameInstanceAs(NoopTagMapBuilder.INSTANCE);
    tagsComponent.setState(TaggingState.ENABLED);
    TagContextBuilder builder = getResultOfCurrentBuilder(tags);
    assertThat(builder).isInstanceOf(TagMapBuilderImpl.class);
    assertThat(tagContextToList(builder.build())).containsExactly(TAG1);
}
Also used : TagContext(io.opencensus.tags.TagContext) TagContextBuilder(io.opencensus.tags.TagContextBuilder) Test(org.junit.Test)

Example 12 with TagContextBuilder

use of io.opencensus.tags.TagContextBuilder in project instrumentation-java by census-instrumentation.

the class TaggerImplTest method currentBuilder_DefaultIsEmpty.

@Test
public void currentBuilder_DefaultIsEmpty() {
    TagContextBuilder currentBuilder = tagger.currentBuilder();
    assertThat(currentBuilder).isInstanceOf(TagMapBuilderImpl.class);
    assertThat(tagContextToList(currentBuilder.build())).isEmpty();
}
Also used : TagContextBuilder(io.opencensus.tags.TagContextBuilder) Test(org.junit.Test)

Example 13 with TagContextBuilder

use of io.opencensus.tags.TagContextBuilder in project instrumentation-java by census-instrumentation.

the class TaggerImplTest method toBuilder_TaggingReenabled.

@Test
public void toBuilder_TaggingReenabled() {
    TagContext tags = new SimpleTagContext(TAG1);
    tagsComponent.setState(TaggingState.DISABLED);
    assertThat(tagger.toBuilder(tags)).isSameInstanceAs(NoopTagMapBuilder.INSTANCE);
    tagsComponent.setState(TaggingState.ENABLED);
    TagContextBuilder builder = tagger.toBuilder(tags);
    assertThat(builder).isInstanceOf(TagMapBuilderImpl.class);
    assertThat(tagContextToList(builder.build())).containsExactly(TAG1);
}
Also used : TagContext(io.opencensus.tags.TagContext) TagContextBuilder(io.opencensus.tags.TagContextBuilder) Test(org.junit.Test)

Example 14 with TagContextBuilder

use of io.opencensus.tags.TagContextBuilder in project instrumentation-java by census-instrumentation.

the class TaggerImplTest method currentBuilder_SkipNullTag.

@Test
public void currentBuilder_SkipNullTag() {
    TagContext tagContextWithNullTag = new SimpleTagContext(TAG1, null, TAG2);
    TagContextBuilder result = getResultOfCurrentBuilder(tagContextWithNullTag);
    assertThat(tagContextToList(result.build())).containsExactly(TAG1, TAG2);
}
Also used : TagContext(io.opencensus.tags.TagContext) TagContextBuilder(io.opencensus.tags.TagContextBuilder) Test(org.junit.Test)

Example 15 with TagContextBuilder

use of io.opencensus.tags.TagContextBuilder in project instrumentation-java by census-instrumentation.

the class TaggerImplTest method currentBuilder.

@Test
public void currentBuilder() {
    TagContext tags = new SimpleTagContext(TAG1, TAG2, TAG3);
    TagContextBuilder result = getResultOfCurrentBuilder(tags);
    assertThat(result).isInstanceOf(TagMapBuilderImpl.class);
    assertThat(tagContextToList(result.build())).containsExactly(TAG1, TAG2, TAG3);
}
Also used : TagContext(io.opencensus.tags.TagContext) TagContextBuilder(io.opencensus.tags.TagContextBuilder) Test(org.junit.Test)

Aggregations

TagContextBuilder (io.opencensus.tags.TagContextBuilder)15 Test (org.junit.Test)13 TagContext (io.opencensus.tags.TagContext)9 Tag (io.opencensus.tags.Tag)2 Scope (io.opencensus.common.Scope)1 ViewData (io.opencensus.stats.ViewData)1 SpanBuilder (io.opencensus.trace.SpanBuilder)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Random (java.util.Random)1