JaegerTracer implements Tracer, Closeable { @Override public JaegerTracer.SpanBuilder buildSpan(String operationName) { return objectFactory.createSpanBuilder(this, operationName); } protected  JaegerTracer(JaegerTracer.Builder builder); String getVersion(); Metrics getMetrics(); String getServiceName(); Map<String, ?> tags(); int getIpv4(); @Override ScopeManager scopeManager(); @Override Span activeSpan(); @Override JaegerTracer.SpanBuilder buildSpan(String operationName); @Override void inject(SpanContext spanContext, Format<T> format, T carrier); @Override JaegerSpanContext extract(Format<T> format, T carrier); @Override void close(); static String getVersionFromProperties(); boolean isUseTraceId128Bit(); @Override Scope activateSpan(Span span);  }
@Test public void testBuildSpan() { String expectedOperation = "fry"; JaegerSpan jaegerSpan = tracer.buildSpan(expectedOperation).start(); assertEquals(expectedOperation, jaegerSpan.getOperationName()); }
@Test public void testTracerMetrics() { String expectedOperation = "fry"; tracer.buildSpan(expectedOperation).start(); assertEquals(1, metricsFactory.getCounter("jaeger_tracer_started_spans", "sampled=y")); assertEquals(0, metricsFactory.getCounter("jaeger_tracer_started_spans", "sampled=n")); assertEquals(1, metricsFactory.getCounter("jaeger_tracer_traces", "sampled=y,state=started")); assertEquals(0, metricsFactory.getCounter("jaeger_tracer_traces", "sampled=n,state=started")); }
@Test public void testBuilderIsServerRpc() { JaegerTracer.SpanBuilder spanBuilder = tracer.buildSpan("ndnd"); spanBuilder.withTag(Tags.SPAN_KIND.getKey(), "server"); assertTrue(spanBuilder.isRpcServer()); }
@Test public void testBuilderIsNotServerRpc() { JaegerTracer.SpanBuilder spanBuilder = tracer.buildSpan("Lrrr"); spanBuilder.withTag(Tags.SPAN_KIND.getKey(), "peachy"); assertFalse(spanBuilder.isRpcServer()); }
@Test public void testSpanContextNotSampled() { String expectedOperation = "fry"; JaegerSpan first = tracer.buildSpan(expectedOperation).start(); tracer.buildSpan(expectedOperation).asChildOf((first.context()).withFlags((byte) 0)).start(); assertEquals(1, metricsFactory.getCounter("jaeger_tracer_started_spans", "sampled=y")); assertEquals(1, metricsFactory.getCounter("jaeger_tracer_started_spans", "sampled=n")); assertEquals(1, metricsFactory.getCounter("jaeger_tracer_traces", "sampled=y,state=started")); assertEquals(0, metricsFactory.getCounter("jaeger_tracer_traces", "sampled=n,state=started")); }
@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(); }