use of io.opentracing.propagation.TextMap in project jaeger-client-java by jaegertracing.
the class B3TextMapCodecResiliencyTest method validHeaders.
private TextMap validHeaders() {
TextMap maliciousCarrier = new B3TextMapCodecTest.DelegatingTextMap();
String validInput = "ffffffffffffffffffffffffffffffff";
maliciousCarrier.put(TRACE_ID_NAME, validInput);
maliciousCarrier.put(SPAN_ID_NAME, validInput);
maliciousCarrier.put(PARENT_SPAN_ID_NAME, validInput);
return maliciousCarrier;
}
use of io.opentracing.propagation.TextMap in project incubator-skywalking by apache.
the class SkywalkingTracerExtractInterceptor method afterMethod.
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
Format format = (Format) allArguments[0];
if (Format.Builtin.TEXT_MAP.equals(format) || Format.Builtin.HTTP_HEADERS.equals(format)) {
TextMap textMapCarrier = (TextMap) allArguments[1];
ContextCarrier contextCarrier = new ContextCarrier();
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
Iterator<Map.Entry<String, String>> iterator = textMapCarrier.iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();
if (next.getHeadKey().equals(entry.getKey())) {
next.setHeadValue(entry.getValue());
break;
}
}
}
ContextManager.extract(contextCarrier);
}
return new SkywalkingContext();
}
use of io.opentracing.propagation.TextMap in project incubator-skywalking by apache.
the class SkywalkingSpanActivationTest method testExtractWithValidateContext.
@Test
public void testExtractWithValidateContext() throws Throwable {
spanBuilder.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).withTag(Tags.PEER_HOST_IPV4.getKey(), "127.0.0.1").withTag(Tags.PEER_PORT.getKey(), 8080);
startSpan();
final Map<String, String> values = new HashMap<String, String>();
TextMap carrier = new TextMap() {
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return values.entrySet().iterator();
}
@Override
public void put(String key, String value) {
values.put(key, value);
}
};
values.put(SW3CarrierItem.HEADER_NAME, "1.343.222|3|1|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|434.12.12123");
extractInterceptor.afterMethod(enhancedInstance, null, new Object[] { Format.Builtin.TEXT_MAP, carrier }, new Class[] {}, null);
stopSpan();
TraceSegment tracingSegment = assertTraceSemgnets();
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(tracingSegment);
assertThat(tracingSegment.getRefs().size(), is(1));
TraceSegmentRef ref = tracingSegment.getRefs().get(0);
SegmentRefAssert.assertSegmentId(ref, "1.343.222");
SegmentRefAssert.assertSpanId(ref, 3);
SegmentRefAssert.assertEntryApplicationInstanceId(ref, 1);
SegmentRefAssert.assertPeerHost(ref, "127.0.0.1:8080");
assertThat(spans.size(), is(1));
assertSpanCommonsAttribute(spans.get(0));
}
use of io.opentracing.propagation.TextMap in project incubator-skywalking by apache.
the class SkywalkingSpanActivationTest method testInject.
@Test
public void testInject() throws Throwable {
spanBuilder.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).withTag(Tags.PEER_HOST_IPV4.getKey(), "127.0.0.1").withTag(Tags.PEER_PORT.getKey(), 8080);
startSpan();
final Map<String, String> values = new HashMap<String, String>();
TextMap carrier = new TextMap() {
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return null;
}
@Override
public void put(String key, String value) {
values.put(key, value);
}
};
injectInterceptor.afterMethod(enhancedInstance, null, new Object[] { new TextMapContext(), Format.Builtin.TEXT_MAP, carrier }, null, null);
String[] parts = values.get(SW3CarrierItem.HEADER_NAME).split("\\|", 8);
Assert.assertEquals("0", parts[1]);
Assert.assertEquals("#127.0.0.1:8080", parts[4]);
Assert.assertTrue(new ID(parts[7]).isValid());
stopSpan();
}
use of io.opentracing.propagation.TextMap in project incubator-skywalking by apache.
the class SkywalkingSpanActivationTest method testExtractWithInValidateContext.
@Test
public void testExtractWithInValidateContext() throws Throwable {
spanBuilder.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).withTag(Tags.PEER_HOST_IPV4.getKey(), "127.0.0.1").withTag(Tags.PEER_PORT.getKey(), 8080);
startSpan();
final Map<String, String> values = new HashMap<String, String>();
TextMap carrier = new TextMap() {
@Override
public Iterator<Map.Entry<String, String>> iterator() {
return values.entrySet().iterator();
}
@Override
public void put(String key, String value) {
values.put(key, value);
}
};
values.put(SW3CarrierItem.HEADER_NAME, "aaaaaaaa|3|#192.168.1.8:18002|#/portal/|#/testEntrySpan|1.234.444");
extractInterceptor.afterMethod(enhancedInstance, null, new Object[] { Format.Builtin.TEXT_MAP, carrier }, new Class[] {}, null);
stopSpan();
TraceSegment tracingSegment = assertTraceSemgnets();
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(tracingSegment);
assertNull(tracingSegment.getRefs());
assertSpanCommonsAttribute(spans.get(0));
}
Aggregations