本文整理匯總了Java中io.opentracing.Tracer.SpanBuilder方法的典型用法代碼示例。如果您正苦於以下問題:Java Tracer.SpanBuilder方法的具體用法?Java Tracer.SpanBuilder怎麽用?Java Tracer.SpanBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.opentracing.Tracer
的用法示例。
在下文中一共展示了Tracer.SpanBuilder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildAndFinishChildSpan
import io.opentracing.Tracer; //導入方法依賴的package包/類
private void buildAndFinishChildSpan(ConsumerRecord<K, V> record) {
SpanContext parentContext = TracingKafkaUtils.extract(record.headers(), tracer);
if (parentContext != null) {
Tracer.SpanBuilder spanBuilder = tracer.buildSpan("receive")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
spanBuilder.addReference(References.FOLLOWS_FROM, parentContext);
Span span = spanBuilder.start();
SpanDecorator.onResponse(record, span);
span.finish();
// Inject created span context into record headers for extraction by client to continue span chain
TracingKafkaUtils.injectSecond(span.context(), record.headers(), tracer);
}
}
示例2: buildSpan
import io.opentracing.Tracer; //導入方法依賴的package包/類
private Scope buildSpan(Tracer tracer, String operationName, StatementInformation statementInformation) {
try {
final Scope activeScope = tracer.scopeManager().active();
final String dbUrl =
statementInformation.getConnectionInformation().getConnection().getMetaData().getURL();
if (withActiveSpanOnly(dbUrl) && activeScope == null) {
return NoopScopeManager.NoopScope.INSTANCE;
}
final Tracer.SpanBuilder spanBuilder = tracer
.buildSpan(operationName)
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
if (activeScope != null) {
spanBuilder.asChildOf(activeScope.span());
}
final Scope scope = spanBuilder.startActive(true);
decorate(scope.span(), statementInformation);
return scope;
} catch (SQLException e) {
return NoopScopeManager.NoopScope.INSTANCE;
}
}
示例3: buildChildSpan
import io.opentracing.Tracer; //導入方法依賴的package包/類
static Scope buildChildSpan(AMQP.BasicProperties props, Tracer tracer) {
SpanContext context = TracingUtils.extract(props, tracer);
if (context != null) {
Tracer.SpanBuilder spanBuilder = tracer.buildSpan("receive")
.ignoreActiveSpan()
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CONSUMER);
spanBuilder.addReference(References.FOLLOWS_FROM, context);
Scope scope = spanBuilder.startActive(true);
SpanDecorator.onResponse(scope.span());
return scope;
}
return null;
}
示例4: filter
import io.opentracing.Tracer; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext context) throws IOException {
if (!shouldFilter(context, resourceInfo)) {
// do nothing if the filter doesn't apply
return;
}
try {
Tracer.SpanBuilder builder = tracer.buildSpan(getOperationName(context, resourceInfo))
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
.withTag(Tags.HTTP_METHOD.getKey(), context.getMethod())
.withTag(Tags.HTTP_URL.getKey(), context.getUriInfo().getAbsolutePath().toString());
builder.asChildOf(tracer.extract(Format.Builtin.HTTP_HEADERS, new ContainerRequestContextTextMap(context)));
final Span span = builder.startManual();
context.setProperty(SERVER_SPAN_CONTEXT_KEY, span);
} catch (Exception e) {
LOGGER.error("Server Request Filter failed", e);
}
}
示例5: buildAndInjectSpan
import io.opentracing.Tracer; //導入方法依賴的package包/類
/**
* Build span and inject. Should be used by producers.
*
* @param message JMS message
* @return span
*/
public static Span buildAndInjectSpan(Destination destination, final Message message,
Tracer tracer)
throws JMSException {
Tracer.SpanBuilder spanBuilder = tracer.buildSpan(TracingMessageUtils.OPERATION_NAME_SEND)
.ignoreActiveSpan()
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_PRODUCER);
SpanContext parent = TracingMessageUtils.extract(message, tracer);
if (parent != null) {
spanBuilder.asChildOf(parent);
}
Span span = spanBuilder.startManual();
SpanJmsDecorator.onRequest(destination, span);
TracingMessageUtils.inject(span, message, tracer);
return span;
}
開發者ID:Estafet-LTD,項目名稱:estafet-microservices-scrum-api-project-burndown,代碼行數:27,代碼來源:PropagatingTracingMessageUtils.java
示例6: buildAndInjectSpan
import io.opentracing.Tracer; //導入方法依賴的package包/類
/**
* Build span and inject. Should be used by producers.
*
* @param message JMS message
* @return span
*/
public static Span buildAndInjectSpan(Destination destination, final Message message,
Tracer tracer) {
Tracer.SpanBuilder spanBuilder = tracer.buildSpan(TracingMessageUtils.OPERATION_NAME_SEND)
.ignoreActiveSpan()
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_PRODUCER);
SpanContext parent = TracingMessageUtils.extract(message, tracer);
if (parent != null) {
spanBuilder.asChildOf(parent);
}
Span span = spanBuilder.start();
SpanJmsDecorator.onRequest(destination, span);
TracingMessageUtils.inject(span, message, tracer);
return span;
}
示例7: buildScope
import io.opentracing.Tracer; //導入方法依賴的package包/類
static Scope buildScope(String operationName, String sql, String dbType, String dbUser,
boolean withActiveSpanOnly) {
if (withActiveSpanOnly && GlobalTracer.get().activeSpan() == null) {
return NoopScope.INSTANCE;
}
Tracer.SpanBuilder spanBuilder = GlobalTracer.get().buildSpan(operationName)
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
Scope scope = spanBuilder.startActive(true);
decorate(scope.span(), sql, dbType, dbUser);
return scope;
}
示例8: processRefererTrace
import io.opentracing.Tracer; //導入方法依賴的package包/類
protected Result processRefererTrace(Tracer tracer, Invoker<?> invoker, Invocation inv) {
String operationName = JbootDubboTracingFilterKits.buildOperationName(invoker,inv);
Tracer.SpanBuilder spanBuilder = tracer.buildSpan(operationName);
Span activeSpan = JbootDubboTracingFilterKits.getActiveSpan();
if (activeSpan != null) {
spanBuilder.asChildOf(activeSpan);
}
Span span = spanBuilder.startManual();
// span.setTag("requestId", request.getRequestId());
attachTraceInfo(tracer, span, inv);
return JbootDubboTracingFilterKits.process(invoker, inv, span);
}
示例9: processRefererTrace
import io.opentracing.Tracer; //導入方法依賴的package包/類
/**
* process trace in client end
*
* @param caller
* @param request
* @return
*/
protected Response processRefererTrace(Tracer tracer, Caller<?> caller, Request request) {
String operationName = buildOperationName(request);
Tracer.SpanBuilder spanBuilder = tracer.buildSpan(operationName);
Span activeSpan = getActiveSpan();
if (activeSpan != null) {
spanBuilder.asChildOf(activeSpan);
}
Span span = spanBuilder.startManual();
span.setTag("requestId", request.getRequestId());
attachTraceInfo(tracer, span, request);
return process(caller, request, span);
}
示例10: buildSpan
import io.opentracing.Tracer; //導入方法依賴的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;
}
示例11: filter
import io.opentracing.Tracer; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
Tracer.SpanBuilder builder = tracer.buildSpan(getOperationName(requestContext, resourceInfo))
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
.withTag(Tags.HTTP_URL.getKey(), requestContext.getUri().toString())
.withTag(Tags.HTTP_METHOD.getKey(), requestContext.getMethod())
.withTag(Tags.PEER_HOSTNAME.getKey(), requestContext.getUri().getHost())
.withTag(Tags.PEER_PORT.getKey(), requestContext.getUri().getPort());
final Span span = builder.startManual();
tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new ClientRequestContextTextMap(requestContext));
requestContext.setProperty(CLIENT_SPAN_CONTEXT_KEY, span);
}
示例12: startChildSpan
import io.opentracing.Tracer; //導入方法依賴的package包/類
/**
* Start a new child span of the active span.
*
* The child span must be finished using {@link #finishChildSpan} before
* completing the service request which created the span.
*
* If there is no active span, the newly created span is made the active
* span.
*
* @param operationName The operation name to give the new child span.
*
* @return The new child span.
*/
private Span startChildSpan(String operationName) {
ActiveSpan activeSpan = tracer.activeSpan();
Tracer.SpanBuilder spanBuilder = tracer.buildSpan(operationName);
if (activeSpan != null) {
spanBuilder.asChildOf(activeSpan.context());
}
Span childSpan = spanBuilder.startManual();
if (activeSpan == null) {
tracer.makeActive(childSpan);
}
childSpan.setTag(LOCAL_SPAN_TAG_KEY, LOCAL_SPAN_TAG_VALUE);
return childSpan;
}
示例13: doExecute
import io.opentracing.Tracer; //導入方法依賴的package包/類
@Override
protected <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void doExecute(
Action<Request, Response, RequestBuilder> action, Request request,
ActionListener<Response> listener) {
Tracer.SpanBuilder spanBuilder = tracer.buildSpan(request.getClass().getSimpleName())
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
Span span = spanBuilder.start();
SpanDecorator.onRequest(span);
ActionListener<Response> actionFuture = new TracingResponseListener<>(listener, span);
super.doExecute(action, request, actionFuture);
}
開發者ID:opentracing-contrib,項目名稱:java-elasticsearch-client,代碼行數:14,代碼來源:TracingPreBuiltTransportClient.java
示例14: withTag
import io.opentracing.Tracer; //導入方法依賴的package包/類
@Override
public Tracer.SpanBuilder withTag(String s, boolean b) {
throw new NotImplementedException();
}
示例15: withStartTimestamp
import io.opentracing.Tracer; //導入方法依賴的package包/類
@Override
public Tracer.SpanBuilder withStartTimestamp(long l) {
wrapped = wrapped.withStartTimestamp(l);
return this;
}