本文整理汇总了Java中io.opentracing.Span.context方法的典型用法代码示例。如果您正苦于以下问题:Java Span.context方法的具体用法?Java Span.context怎么用?Java Span.context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.opentracing.Span
的用法示例。
在下文中一共展示了Span.context方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import io.opentracing.Span; //导入方法依赖的package包/类
/**
* Extract context from headers or from active Span
*
* @param request http request
* @return extracted context
*/
private SpanContext extract(HttpRequest request) {
SpanContext spanContext = tracer.extract(Format.Builtin.HTTP_HEADERS,
new HttpTextMapExtractAdapter(request));
if (spanContext != null) {
return spanContext;
}
Span span = tracer.activeSpan();
if (span != null) {
return span.context();
}
return null;
}
开发者ID:opentracing-contrib,项目名称:java-elasticsearch-client,代码行数:22,代码来源:TracingHttpClientConfigCallback.java
示例2: extract
import io.opentracing.Span; //导入方法依赖的package包/类
public static SpanContext extract(AMQP.BasicProperties props, Tracer tracer) {
SpanContext spanContext = tracer
.extract(Format.Builtin.TEXT_MAP, new HeadersMapExtractAdapter(props.getHeaders()));
if (spanContext != null) {
return spanContext;
}
Span span = tracer.activeSpan();
if (span != null) {
return span.context();
}
return null;
}
示例3: buildSpan
import io.opentracing.Span; //导入方法依赖的package包/类
private Scope buildSpan(String exchange, AMQP.BasicProperties props) {
Tracer.SpanBuilder spanBuilder = tracer.buildSpan("send")
.ignoreActiveSpan()
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_PRODUCER);
SpanContext spanContext = null;
if (props != null && props.getHeaders() != null) {
// just in case if span context was injected manually to props in basicPublish
spanContext = tracer.extract(Format.Builtin.TEXT_MAP,
new HeadersMapExtractAdapter(props.getHeaders()));
}
if (spanContext == null) {
Span parentSpan = tracer.activeSpan();
if (parentSpan != null) {
spanContext = parentSpan.context();
}
}
if (spanContext != null) {
spanBuilder.asChildOf(spanContext);
}
Scope scope = spanBuilder.startActive(true);
SpanDecorator.onRequest(exchange, scope.span());
return scope;
}
示例4: extract
import io.opentracing.Span; //导入方法依赖的package包/类
/**
* Extract span context from JMS message properties or active span
*
* @param message JMS message
* @param tracer Tracer
* @return extracted span context
*/
public static SpanContext extract(Message message, Tracer tracer) {
SpanContext spanContext = tracer
.extract(Format.Builtin.TEXT_MAP, new JmsTextMapExtractAdapter(message));
if (spanContext != null) {
return spanContext;
}
Span span = tracer.activeSpan();
if (span != null) {
return span.context();
}
return null;
}
示例5: serverSpanContext
import io.opentracing.Span; //导入方法依赖的package包/类
/**
* Helper method for accessing server span context associated with current request.
*
* @param routingContext routing context
* @return server span context or null if not present
*/
public static SpanContext serverSpanContext(RoutingContext routingContext) {
SpanContext serverContext = null;
Object object = routingContext.get(CURRENT_SPAN);
if (object instanceof Span) {
Span span = (Span) object;
serverContext = span.context();
} else {
log.error("Sever SpanContext is null or not an instance of SpanContext");
}
return serverContext;
}