Search in sources :

Example 56 with TagContext

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

the class ScopedTagMapTest method defaultTagContext.

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

Example 57 with TagContext

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

the class CurrentTagMapUtilsTest method testGetCurrentTagMap_DefaultContext.

@Test
public void testGetCurrentTagMap_DefaultContext() {
    TagContext tags = CurrentTagMapUtils.getCurrentTagMap();
    assertThat(tags).isNotNull();
    assertThat(tagContextToList(tags)).isEmpty();
}
Also used : TagContext(io.opencensus.tags.TagContext) Test(org.junit.Test)

Example 58 with TagContext

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

the class TagMapImplTest method remove_existingKey.

@Test
public void remove_existingKey() {
    TagContext tags = new TagMapImpl(ImmutableMap.of(K1, VM1, K2, VM2));
    assertThat(((TagMapImpl) tagger.toBuilder(tags).remove(K1).build()).getTags()).containsExactly(K2, VM2);
}
Also used : TagContext(io.opencensus.tags.TagContext) Test(org.junit.Test)

Example 59 with TagContext

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

the class TagMapImplTest method put_nullValue.

@Test
public void put_nullValue() {
    TagContext tags = new TagMapImpl(ImmutableMap.of(K1, VM1));
    TagContextBuilder builder = tagger.toBuilder(tags);
    thrown.expect(NullPointerException.class);
    thrown.expectMessage("value");
    builder.put(K2, null);
}
Also used : TagContext(io.opencensus.tags.TagContext) TagContextBuilder(io.opencensus.tags.TagContextBuilder) Test(org.junit.Test)

Example 60 with TagContext

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

the class CorrelationContextFormatTest method extract_OverrideTagWithSpaces.

@Test
public void extract_OverrideTagWithSpaces() throws TagContextDeserializationException {
    Map<String, String> carrier = Collections.singletonMap(CORRELATION_CONTEXT, "k1= v1, k1=v2 ");
    Tag expected = Tag.create(K1, V2, METADATA_UNLIMITED_PROPAGATION);
    TagContext tagContext = textFormat.extract(carrier, getter);
    assertThat(TagsTestUtil.tagContextToList(tagContext)).containsExactly(expected);
}
Also used : TagContext(io.opencensus.tags.TagContext) Tag(io.opencensus.tags.Tag) 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