Java Code Examples for io.opentracing.propagation.TextMap#put()

The following examples show how to use io.opentracing.propagation.TextMap#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkywalkingTracerInjectInterceptor.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    Object ret) throws Throwable {
    Format format = (Format) allArguments[1];
    if (Format.Builtin.TEXT_MAP.equals(format) || Format.Builtin.HTTP_HEADERS.equals(format)) {
        TextMap carrier = (TextMap) allArguments[2];
        ContextCarrier contextCarrier = new ContextCarrier();
        ContextManager.inject(contextCarrier);
        CarrierItem next = contextCarrier.items();
        while (next.hasNext()) {
            next = next.next();
            carrier.put(next.getHeadKey(), next.getHeadValue());
        }
    } else {
        //Don't support other format yet.
    }

    return null;
}
 
Example 2
Source File: ElasticApmTracer.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@Override
public <C> void inject(SpanContext spanContext, Format<C> format, C carrier) {
    if (format == Format.Builtin.HTTP_HEADERS || format == Format.Builtin.TEXT_MAP) {
        TextMap textMap = (TextMap) carrier;
        for (Map.Entry<String, String> baggageItem : spanContext.baggageItems()) {
            textMap.put(baggageItem.getKey(), baggageItem.getValue());
        }
    }
}
 
Example 3
Source File: TextMapFormatter.java    From servicetalk with Apache License 2.0 5 votes vote down vote up
@Override
public void inject(InMemoryTraceState state, TextMap carrier) {
    carrier.put(TRACE_ID, state.traceIdHex());
    carrier.put(SPAN_ID, state.spanIdHex());
    if (state.parentSpanIdHex() != null) {
        carrier.put(PARENT_SPAN_ID, state.parentSpanIdHex());
    }
    carrier.put(SAMPLED, state.isSampled() ? "1" : "0");
}
 
Example 4
Source File: AbstractTextFormatter.java    From sofa-tracer with Apache License 2.0 5 votes vote down vote up
@Override
public void inject(SofaTracerSpanContext spanContext, TextMap carrier) {
    if (carrier == null || spanContext == null) {
        return;
    }
    carrier.put(FORMATER_KEY_HEAD, this.encodedValue(spanContext.serializeSpanContext()));
}