use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class JaegerTracerTagsTest method testShortDeclaredIpTag.
@Test
public void testShortDeclaredIpTag() {
InMemoryReporter spanReporter = new InMemoryReporter();
String ip = ":19";
JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withTag(Constants.TRACER_IP_TAG_KEY, ip).build();
assertEquals(0, tracer.getIpv4());
}
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 ThriftSpanConverterTest method testTracerTags.
@Test
@UseDataProvider("dataProviderTracerTags")
public void testTracerTags(SpanType spanType, Map<String, String> expectedTags) {
InMemoryReporter spanReporter = new InMemoryReporter();
JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withSampler(new ConstSampler(true)).withZipkinSharedRpcSpan().withTag("tag.str", "y").withTag("tag.bool", true).withTag("tag.num", 1).build();
JaegerSpan span = tracer.buildSpan("root").start();
if (spanType == SpanType.CHILD) {
span = tracer.buildSpan("child").asChildOf(span).start();
} else if (spanType == SpanType.RPC_SERVER) {
span = tracer.buildSpan("rpc-server").asChildOf(span).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).start();
}
com.twitter.zipkin.thriftjava.Span zipkinSpan = ThriftSpanConverter.convertSpan(span);
List<BinaryAnnotation> annotations = zipkinSpan.getBinary_annotations();
for (Map.Entry<String, String> entry : expectedTags.entrySet()) {
String key = entry.getKey();
Object expectedValue = entry.getValue();
BinaryAnnotation anno = findBinaryAnnotation(annotations, key);
if (expectedValue.equals(UNDEF)) {
assertNull("Not expecting " + key + " for " + spanType, anno);
} else if (expectedValue.equals(ANY)) {
assertEquals(key, anno.getKey());
} else {
String actualValue = new String(anno.getValue(), StandardCharsets.UTF_8);
assertEquals("Expecting " + key + " for " + spanType, expectedValue, actualValue);
}
}
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class V2SpanConverterTest method dataProviderTracerTags.
@DataProvider
public static Object[][] dataProviderTracerTags() {
JaegerTracer tracer = new JaegerTracer.Builder("x").build();
Map<String, String> rootTags = new HashMap<>();
rootTags.put("tracer.jaeger.version", tracer.getVersion());
rootTags.put("tracer.hostname", ANY);
rootTags.put("tracer.tag.str", "y");
rootTags.put("tracer.tag.bool", "true");
rootTags.put("tracer.tag.num", "1");
rootTags.put("sampler.type", "const");
rootTags.put("sampler.param", "true");
Map<String, String> childTags = new HashMap<>();
childTags.put("tracer.jaeger.version", UNDEF);
childTags.put("tracer.hostname", UNDEF);
childTags.put("tracer.tag.str", UNDEF);
childTags.put("tracer.tag.bool", UNDEF);
childTags.put("tracer.tag.num", UNDEF);
childTags.put("sampler.type", UNDEF);
childTags.put("sampler.param", UNDEF);
Map<String, String> rpcTags = new HashMap<>();
rpcTags.put("tracer.jaeger.version", tracer.getVersion());
rpcTags.put("tracer.hostname", ANY);
rpcTags.put("tracer.tag.str", "y");
rpcTags.put("tracer.tag.bool", "true");
rpcTags.put("tracer.tag.num", "1");
rpcTags.put("sampler.type", UNDEF);
rpcTags.put("sampler.param", UNDEF);
return new Object[][] { { SpanType.ROOT, rootTags }, { SpanType.CHILD, childTags }, { SpanType.RPC_SERVER, rpcTags } };
}
Aggregations