Search in sources :

Example 1 with SkywalkingContext

use of org.apache.skywalking.apm.toolkit.opentracing.SkywalkingContext 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();
}
Also used : SkywalkingContext(org.apache.skywalking.apm.toolkit.opentracing.SkywalkingContext) ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) Format(io.opentracing.propagation.Format) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) TextMap(io.opentracing.propagation.TextMap) TextMap(io.opentracing.propagation.TextMap) Map(java.util.Map)

Aggregations

Format (io.opentracing.propagation.Format)1 TextMap (io.opentracing.propagation.TextMap)1 Map (java.util.Map)1 CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)1 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)1 SkywalkingContext (org.apache.skywalking.apm.toolkit.opentracing.SkywalkingContext)1