Search in sources :

Example 1 with StringTag

use of io.opentracing.tag.StringTag in project jaeger-client-java by jaegertracing.

the class JaegerSpanTest method testSetTag.

@Test
public void testSetTag() {
    jaegerSpan.setTag(new StringTag("stringTag"), "stringTagValue").setTag(new IntTag("numberTag"), 1).setTag(new BooleanTag("booleanTag"), true).setTag(new AbstractTag<Object>("objectTag") {

        @Override
        public void set(Span span, Object tagValue) {
        }
    }, this);
    Map<String, Object> tags = jaegerSpan.getTags();
    assertEquals("stringTagValue", tags.get("stringTag"));
    assertEquals(1, tags.get("numberTag"));
    assertEquals(true, tags.get("booleanTag"));
    assertEquals(this, tags.get("objectTag"));
}
Also used : StringTag(io.opentracing.tag.StringTag) BooleanTag(io.opentracing.tag.BooleanTag) Span(io.opentracing.Span) NoopSpan(io.opentracing.noop.NoopSpan) IntTag(io.opentracing.tag.IntTag) Test(org.junit.Test)

Example 2 with StringTag

use of io.opentracing.tag.StringTag in project jaeger-client-java by jaegertracing.

the class JaegerTracerTest method testWithTagObject.

@Test
public void testWithTagObject() {
    JaegerTracer.SpanBuilder spanBuilder = tracer.buildSpan("ndnd");
    spanBuilder.withTag(new StringTag("stringTag"), "stringTagValue").withTag(new IntTag("numberTag"), 1).withTag(new BooleanTag("booleanTag"), true).withTag(new AbstractTag<Object>("objectTag") {

        @Override
        public void set(Span span, Object tagValue) {
        }
    }, this);
    Span span = spanBuilder.start();
    Map<String, Object> tags = ((JaegerSpan) span).getTags();
    assertEquals("stringTagValue", tags.get("stringTag"));
    assertEquals(1, tags.get("numberTag"));
    assertEquals(true, tags.get("booleanTag"));
    assertEquals(this, tags.get("objectTag"));
    span.finish();
}
Also used : StringTag(io.opentracing.tag.StringTag) BooleanTag(io.opentracing.tag.BooleanTag) Span(io.opentracing.Span) IntTag(io.opentracing.tag.IntTag) Test(org.junit.Test)

Aggregations

Span (io.opentracing.Span)2 BooleanTag (io.opentracing.tag.BooleanTag)2 IntTag (io.opentracing.tag.IntTag)2 StringTag (io.opentracing.tag.StringTag)2 Test (org.junit.Test)2 NoopSpan (io.opentracing.noop.NoopSpan)1