本文整理匯總了Java中io.opentracing.Tracer.inject方法的典型用法代碼示例。如果您正苦於以下問題:Java Tracer.inject方法的具體用法?Java Tracer.inject怎麽用?Java Tracer.inject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.opentracing.Tracer
的用法示例。
在下文中一共展示了Tracer.inject方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: attachTraceInfo
import io.opentracing.Tracer; //導入方法依賴的package包/類
protected void attachTraceInfo(Tracer tracer, Span span, final Invocation inv) {
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, new TextMap() {
@Override
public void put(String key, String value) {
inv.getAttachments().put(key, value);
}
@Override
public Iterator<Map.Entry<String, String>> iterator() {
throw new UnsupportedOperationException("TextMapInjectAdapter should only be used with Tracer.inject()");
}
});
}
示例2: attachTraceInfo
import io.opentracing.Tracer; //導入方法依賴的package包/類
protected void attachTraceInfo(Tracer tracer, Span span, final Request request) {
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, new TextMap() {
@Override
public void put(String key, String value) {
request.setAttachment(key, value);
}
@Override
public Iterator<Map.Entry<String, String>> iterator() {
throw new UnsupportedOperationException("TextMapInjectAdapter should only be used with Tracer.inject()");
}
});
}
示例3: testInject
import io.opentracing.Tracer; //導入方法依賴的package包/類
@Test
public void testInject() {
Tracer tracer = new StackDriverOTTracer(Trace.getTracer());
Span span = tracer.buildSpan("Dummy").start();
com.google.cloud.trace.core.SpanContext contextToInject = ((StackDriverOTSpanContext)span.context()).getUnderlyingSpanContext();
Map<String, String> resultingMap = new HashMap<>();
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, new TextMapInjectAdapter(resultingMap));
assertEquals(contextToInject.getTraceId().getApiString(), resultingMap.get(TextMapPropagator.FIELD_TRACE_ID));
assertEquals(contextToInject.getSpanId().getApiString(), resultingMap.get(TextMapPropagator.FIELD_SPAN_ID));
}
示例4: inject
import io.opentracing.Tracer; //導入方法依賴的package包/類
/**
* Inject Span Context to record headers
*
* @param spanContext Span Context
* @param headers record headers
*/
static void inject(SpanContext spanContext, Headers headers,
Tracer tracer) {
tracer.inject(spanContext, Format.Builtin.TEXT_MAP,
new HeadersMapInjectAdapter(headers, false));
}
示例5: injectSecond
import io.opentracing.Tracer; //導入方法依賴的package包/類
/**
* Inject second Span Context to record headers
*
* @param spanContext Span Context
* @param headers record headers
*/
static void injectSecond(SpanContext spanContext, Headers headers,
Tracer tracer) {
tracer.inject(spanContext, Format.Builtin.TEXT_MAP,
new HeadersMapInjectAdapter(headers, true));
}
示例6: inject
import io.opentracing.Tracer; //導入方法依賴的package包/類
/**
* Inject span context to JMS message properties
*
* @param span span
* @param message JMS message
*/
public static void inject(Span span, Message message, Tracer tracer) {
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, new JmsTextMapInjectAdapter(message));
}
開發者ID:Estafet-LTD,項目名稱:estafet-microservices-scrum-api-project-burndown,代碼行數:10,代碼來源:PropagatingTracingMessageUtils.java