Search in sources :

Example 1 with TextMapContext

use of org.apache.skywalking.apm.toolkit.opentracing.TextMapContext 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();
}
Also used : HashMap(java.util.HashMap) TextMapContext(org.apache.skywalking.apm.toolkit.opentracing.TextMapContext) TextMap(io.opentracing.propagation.TextMap) ID(org.apache.skywalking.apm.agent.core.context.ids.ID) Test(org.junit.Test)

Aggregations

TextMap (io.opentracing.propagation.TextMap)1 HashMap (java.util.HashMap)1 ID (org.apache.skywalking.apm.agent.core.context.ids.ID)1 TextMapContext (org.apache.skywalking.apm.toolkit.opentracing.TextMapContext)1 Test (org.junit.Test)1