Search in sources :

Example 66 with TagContext

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

the class TaggerImplTest method withTagContext_ConvertUnknownTagContextToTagMapImpl.

@Test
public void withTagContext_ConvertUnknownTagContextToTagMapImpl() {
    TagContext unknownTagContext = new SimpleTagContext(TAG1, TAG2, TAG3);
    TagContext result = getResultOfWithTagContext(unknownTagContext);
    assertThat(result).isInstanceOf(TagMapImpl.class);
    assertThat(tagContextToList(result)).containsExactly(TAG1, TAG2, TAG3);
}
Also used : TagContext(io.opencensus.tags.TagContext) Test(org.junit.Test)

Example 67 with TagContext

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

the class TaggerImplTest method withTagContext_RemoveDuplicatesFromUnknownTagContext.

@Test
public void withTagContext_RemoveDuplicatesFromUnknownTagContext() {
    Tag tag1 = Tag.create(K1, V1);
    Tag tag2 = Tag.create(K1, V2);
    TagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2);
    TagContext result = getResultOfWithTagContext(tagContextWithDuplicateTags);
    assertThat(tagContextToList(result)).containsExactly(tag2);
}
Also used : TagContext(io.opencensus.tags.TagContext) Tag(io.opencensus.tags.Tag) Test(org.junit.Test)

Example 68 with TagContext

use of io.opencensus.tags.TagContext 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 69 with TagContext

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

the class TaggerImplTest method toBuilder_RemoveDuplicatesFromUnknownTagContext.

@Test
public void toBuilder_RemoveDuplicatesFromUnknownTagContext() {
    Tag tag1 = Tag.create(K1, V1);
    Tag tag2 = Tag.create(K1, V2);
    TagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2);
    TagContext newTagContext = tagger.toBuilder(tagContextWithDuplicateTags).build();
    assertThat(tagContextToList(newTagContext)).containsExactly(tag2);
}
Also used : TagContext(io.opencensus.tags.TagContext) Tag(io.opencensus.tags.Tag) Test(org.junit.Test)

Example 70 with TagContext

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

the class TaggerImplTest method getCurrentTagContext_DefaultIsEmptyTagMapImpl.

@Test
public void getCurrentTagContext_DefaultIsEmptyTagMapImpl() {
    TagContext currentTagContext = tagger.getCurrentTagContext();
    assertThat(tagContextToList(currentTagContext)).isEmpty();
    assertThat(currentTagContext).isInstanceOf(TagMapImpl.class);
}
Also used : TagContext(io.opencensus.tags.TagContext) Test(org.junit.Test)

Aggregations

TagContext (io.opencensus.tags.TagContext)76 Test (org.junit.Test)56 Tag (io.opencensus.tags.Tag)10 TagContextBuilder (io.opencensus.tags.TagContextBuilder)9 ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)7 Context (io.grpc.Context)6 Scope (io.opencensus.common.Scope)5 StatsTestUtil.createEmptyViewData (io.opencensus.implcore.stats.StatsTestUtil.createEmptyViewData)5 View (io.opencensus.stats.View)5 ViewData (io.opencensus.stats.ViewData)5 Metadata (io.grpc.Metadata)3 StatsTestUtils (io.grpc.internal.testing.StatsTestUtils)3 MeasureMap (io.opencensus.stats.MeasureMap)3 TagValue (io.opencensus.tags.TagValue)3 SpanContext (io.opencensus.trace.SpanContext)3 HashMap (java.util.HashMap)3 ServerStreamTracer (io.grpc.ServerStreamTracer)2 CallAttemptsTracerFactory (io.grpc.census.CensusTracingModule.CallAttemptsTracerFactory)2 HttpRequestContext (io.opencensus.contrib.http.HttpRequestContext)2 SimpleTagContext (io.opencensus.implcore.stats.StatsTestUtil.SimpleTagContext)2