use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class JaegerTracerTagsTest method testDeclaredHostTags.
@Test
public void testDeclaredHostTags() {
InMemoryReporter spanReporter = new InMemoryReporter();
String hostname = "myhost";
String ip = "1.1.1.1";
JaegerTracer tracer = new JaegerTracer.Builder("x").withReporter(spanReporter).withTag(Constants.TRACER_HOSTNAME_TAG_KEY, hostname).withTag(Constants.TRACER_IP_TAG_KEY, ip).build();
assertEquals(hostname, tracer.tags().get(Constants.TRACER_HOSTNAME_TAG_KEY));
assertEquals(ip, tracer.tags().get(Constants.TRACER_IP_TAG_KEY));
assertEquals(Utils.ipToInt(ip), tracer.getIpv4());
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class ConfigurationTest method testPropagationB3Only.
@Test
public void testPropagationB3Only() {
System.setProperty(Configuration.JAEGER_PROPAGATION, "b3");
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test");
long traceIdLow = 1234L;
long spanId = 5678L;
TestTextMap textMap = new TestTextMap();
JaegerSpanContext spanContext = new JaegerSpanContext(0, traceIdLow, spanId, 0, (byte) 0);
JaegerTracer tracer = Configuration.fromEnv().getTracer();
tracer.inject(spanContext, Format.Builtin.TEXT_MAP, textMap);
assertNotNull(textMap.get("X-B3-TraceId"));
assertNotNull(textMap.get("X-B3-SpanId"));
assertNull(textMap.get("uber-trace-id"));
JaegerSpanContext extractedContext = tracer.extract(Format.Builtin.TEXT_MAP, textMap);
assertEquals(traceIdLow, extractedContext.getTraceIdLow());
assertEquals(0, extractedContext.getTraceIdHigh());
assertEquals(spanId, extractedContext.getSpanId());
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class ConfigurationTest method testTracerTagsSubstitutionSpecified.
@Test
public void testTracerTagsSubstitutionSpecified() {
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test");
System.setProperty(TEST_PROPERTY, "goodbye");
System.setProperty(Configuration.JAEGER_TAGS, "testTag1=${" + TEST_PROPERTY + ":hello}");
JaegerTracer tracer = Configuration.fromEnv().getTracer();
assertEquals("goodbye", tracer.tags().get("testTag1"));
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class ConfigurationTest method testFromEnvWithExplicitServiceName.
@Test
public void testFromEnvWithExplicitServiceName() {
// prepare
String serviceName = "testFromEnvWithExplicitServiceName";
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "not" + serviceName);
// test
JaegerTracer tracer = Configuration.fromEnv(serviceName).getTracer();
// check
assertEquals(serviceName, tracer.getServiceName());
}
use of io.jaegertracing.internal.JaegerTracer in project jaeger-client-java by jaegertracing.
the class JaegerTracerResolverTest method testResolveTracerDefault.
@Test
public void testResolveTracerDefault() {
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "MyService");
Tracer tracer = TracerResolver.resolveTracer();
assertNotNull(tracer);
assertTrue(tracer instanceof JaegerTracer);
}
Aggregations