use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class RemoteReporterTest method testUpdateErrorMetricWhenCommandExecuteFails.
@Test
public void testUpdateErrorMetricWhenCommandExecuteFails() throws Exception {
int reporterFailures = 5;
sender = new InMemorySender() {
@Override
public int append(JaegerSpan span) throws SenderException {
throw new SenderException("", reporterFailures);
}
};
RemoteReporter reporter = new Builder().withSender(sender).withFlushInterval(flushInterval).withMaxQueueSize(maxQueueSize).withMetrics(metrics).build();
reporter.report(newSpan());
reporter.close();
assertEquals(reporterFailures, metricsFactory.getCounter("jaeger_tracer_reporter_spans", "result=err"));
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class RemoteReporterTest method testRemoteReporterFlushesOnClose.
@Test
public void testRemoteReporterFlushesOnClose() {
int numberOfSpans = 100;
for (int i = 0; i < numberOfSpans; i++) {
JaegerSpan span = tracer.buildSpan("raza").start();
reporter.report(span);
}
reporter.close();
assertEquals(0, sender.getAppended().size());
assertEquals(numberOfSpans, sender.getFlushed().size());
assertEquals(100, metricsFactory.getCounter("jaeger_tracer_started_spans", "sampled=y"));
assertEquals(100, metricsFactory.getCounter("jaeger_tracer_reporter_spans", "result=ok"));
assertEquals(100, metricsFactory.getCounter("jaeger_tracer_traces", "sampled=y,state=started"));
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class RemoteReporterTest method testRemoteReporterReport.
@Test
public void testRemoteReporterReport() {
JaegerSpan span = tracer.buildSpan("raza").start();
reporter.report(span);
// do sleep until automatic flush happens on 'reporter'
// added 20ms on top of 'flushInterval' to avoid corner cases
await().with().pollInterval(1, TimeUnit.MILLISECONDS).atMost(flushInterval + 20, TimeUnit.MILLISECONDS).until(() -> sender.getReceived().size() > 0);
List<JaegerSpan> received = sender.getReceived();
assertEquals(1, received.size());
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class BaggageSetterTest method testOverrideBaggage.
@Test
public void testOverrideBaggage() {
when(mgr.getRestriction(SERVICE, KEY)).thenReturn(Restriction.of(true, 5));
final String value = "value";
JaegerSpanContext ctx = setter.setBaggage(jaegerSpan, KEY, value);
JaegerSpan child = tracer.buildSpan("some-operation").asChildOf(ctx).start();
ctx = setter.setBaggage(child, KEY, value);
assertBaggageLogs(child, KEY, value, false, true, false);
assertEquals(value, ctx.getBaggageItem(KEY));
assertEquals(2, metricsFactory.getCounter("jaeger_tracer_baggage_updates", "result=ok"));
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class BaggageSetterTest method testBaggageNullRemoveValue.
@Test
public void testBaggageNullRemoveValue() {
when(mgr.getRestriction(SERVICE, KEY)).thenReturn(Restriction.of(true, 5));
final String value = "value";
JaegerSpan originalSpan = jaegerSpan.setBaggageItem(KEY, value);
assertEquals(value, originalSpan.getBaggageItem(KEY));
JaegerSpan child = tracer.buildSpan("some-operation").asChildOf(originalSpan).start();
child = child.setBaggageItem(KEY, null);
assertBaggageLogs(child, KEY, null, false, true, false);
assertNull(child.getBaggageItem(KEY));
assertEquals(2, metricsFactory.getCounter("jaeger_tracer_baggage_updates", "result=ok"));
}
Aggregations