use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class MicrometerTest method testExposedMetrics.
@Test
public void testExposedMetrics() {
Configuration configuration = new Configuration("exposedmetrics");
final JaegerTracer tracer = configuration.getTracerBuilder().withMetrics(metrics).build();
// This is a gauge, so it needs to be non-zero to come back from prometheus
metrics.reporterQueueLength.update(1);
List<Meter> meters = new ArrayList<>(prometheusRegistry.getMeters());
Map<String, Long> metricCounts = meters.stream().collect(groupingBy(m -> m.getId().getName(), counting()));
assertEquals("Wrong number of metrics collected", expectedMetricCounts.size(), metricCounts.keySet().size());
for (String name : metricCounts.keySet()) {
assertTrue("Unexpected metric " + name, expectedMetricCounts.containsKey(name));
}
for (String metricName : expectedMetricCounts.keySet()) {
assertTrue("Did not find metric " + metricName, metricCounts.containsKey(metricName));
assertEquals("Wrong count for " + metricName, expectedMetricCounts.get(metricName), metricCounts.get(metricName));
}
tracer.close();
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class MicrometerTest method validateMetricCounts.
@Test
public void validateMetricCounts() throws InterruptedException {
Sampler constantSampler = new ConstSampler(true);
Configuration configuration = new Configuration("validateMetricCounts");
JaegerTracer tracer = configuration.getTracerBuilder().withSampler(constantSampler).withMetrics(metrics).build();
createSomeSpans(tracer);
tracer.close();
double finishedSpans = registry.get("jaeger_tracer_finished_spans").counter().count();
double startedSpans = registry.get("jaeger_tracer_started_spans").tag("sampled", "y").counter().count();
double traces = registry.get("jaeger_tracer_traces").tag("sampled", "y").tag("state", "started").counter().count();
assertEquals("Wrong number of finishedSpans", 4.0, finishedSpans, assertDelta);
assertEquals("Wrong number of startedSpans", 10.0, startedSpans, assertDelta);
assertEquals("Wrong number of traces", 10.0, traces, assertDelta);
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class TraceContextCodecTest method testDebugIdWithoutTraceHeader.
@Test
public void testDebugIdWithoutTraceHeader() {
Map<String, String> extractCarrier = new HashMap<>();
TextMapAdapter textMap = new TextMapAdapter(extractCarrier);
textMap.put(Constants.DEBUG_ID_HEADER_KEY, EXAMPLE_DEBUG_ID);
JaegerSpanContext spanContext = traceContextCodec.extract(textMap);
JaegerTracer tracer = new JaegerTracer.Builder("service").withReporter(new InMemoryReporter()).build();
JaegerSpan child = tracer.buildSpan("span").asChildOf(spanContext).start();
assertTrue(child.context().isDebug());
child.finish();
tracer.close();
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class NoopMetricsFactoryTest method canBeUsedWithMetrics.
@Test
public void canBeUsedWithMetrics() {
NoopMetricsFactory metricsFactory = new NoopMetricsFactory();
JaegerTracer tracer = new JaegerTracer.Builder("metricsFactoryTest").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
tracer.buildSpan("theoperation").start();
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class ConfigurationTest method testTracerUse128BitTraceId.
@Test
public void testTracerUse128BitTraceId() {
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test");
System.setProperty(Configuration.JAEGER_TRACEID_128BIT, "true");
JaegerTracer tracer = Configuration.fromEnv().getTracer();
assertTrue(tracer.isUseTraceId128Bit());
}
Aggregations