io.opencensus.trace.Tracer.spanBuilderWithRemoteParent()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中io.opencensus.trace.Tracer.spanBuilderWithRemoteParent()方法的一些代码示例,展示了Tracer.spanBuilderWithRemoteParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tracer.spanBuilderWithRemoteParent()方法的具体详情如下:
包路径:io.opencensus.trace.Tracer
类名称:Tracer
方法名:spanBuilderWithRemoteParent

Tracer.spanBuilderWithRemoteParent介绍

[英]Returns a SpanBuilder to create and start a new child Span (or root if parent is SpanContext#INVALID or null), with parent being the remote Spandesignated by the SpanContext.

See SpanBuilder for usage examples.

This must be used to create a Span when the parent is in a different process. This is only intended for use by RPC systems or similar.

If no SpanContext OR fail to parse the SpanContext on the server side, users must call this method with a null remote parent SpanContext.
[中]返回SpanBuilder以创建和启动新的子Span(如果父级为SpanContext#无效或空,则返回root),父级为SpanContext指定的远程SpanContext。
有关用法示例,请参见SpanBuilder。
当父进程处于不同的进程中时,必须使用此选项来创建跨度。这仅适用于RPC系统或类似系统。
如果没有SpanContext或无法在服务器端解析SpanContext,用户必须使用空的远程父SpanContext调用此方法。

代码示例

代码示例来源:origin: io.grpc/grpc-core

ServerTracer(String fullMethodName, @Nullable SpanContext remoteSpan) {
 checkNotNull(fullMethodName, "fullMethodName");
 this.span =
   censusTracer
     .spanBuilderWithRemoteParent(
       generateTraceSpanName(true, fullMethodName),
       remoteSpan)
     .setRecordEvents(true)
     .startSpan();
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

ServerTracer(String fullMethodName, @Nullable SpanContext remoteSpan) {
 checkNotNull(fullMethodName, "fullMethodName");
 this.span =
   censusTracer
     .spanBuilderWithRemoteParent(
       generateTraceSpanName(true, fullMethodName),
       remoteSpan)
     .setRecordEvents(true)
     .startSpan();
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test(expected = NullPointerException.class)
public void spanBuilderWithRemoteParent_NullName() {
 noopTracer.spanBuilderWithRemoteParent(null, null);
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void handleStartShouldCreateChildSpanUnderParent() throws SpanContextParseException {
 HttpRequestContext context = handler.handleStart(carrier, request);
 verify(tracer).spanBuilderWithRemoteParent(any(String.class), same(spanContextRemote));
 assertThat(context.span).isEqualTo(spanWithRemoteParent);
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void defaultSpanBuilderWithRemoteParent() {
 assertThat(noopTracer.spanBuilderWithRemoteParent(SPAN_NAME, SpanContext.INVALID).startSpan())
   .isSameAs(BlankSpan.INSTANCE);
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void defaultSpanBuilderWithRemoteParent_NullParent() {
 assertThat(noopTracer.spanBuilderWithRemoteParent(SPAN_NAME, null).startSpan())
   .isSameAs(BlankSpan.INSTANCE);
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Before
public void setUp() throws SpanContextParseException {
 MockitoAnnotations.initMocks(this);
 handler =
   new HttpServerHandler<Object, Object, Object>(
     tracer, extractor, textFormat, textFormatGetter, false);
 handlerForPublicEndpoint =
   new HttpServerHandler<Object, Object, Object>(
     tracer, extractor, textFormat, textFormatGetter, true);
 when(tracer.spanBuilderWithRemoteParent(any(String.class), same(spanContextRemote)))
   .thenReturn(spanBuilderWithRemoteParent);
 when(tracer.spanBuilderWithExplicitParent(any(String.class), any(Span.class)))
   .thenReturn(spanBuilderWithLocalParent);
 when(spanBuilderWithRemoteParent.startSpan()).thenReturn(spanWithRemoteParent);
 when(spanBuilderWithLocalParent.startSpan()).thenReturn(spanWithLocalParent);
 when(textFormat.extract(same(carrier), same(textFormatGetter))).thenReturn(spanContextRemote);
}

代码示例来源:origin: io.opencensus/opencensus-contrib-http-util

spanBuilder = tracer.spanBuilder(spanName);
} else {
 spanBuilder = tracer.spanBuilderWithRemoteParent(spanName, spanContext);

代码示例来源:origin: census-instrumentation/opencensus-java

spanBuilder = tracer.spanBuilder(spanName);
} else {
 spanBuilder = tracer.spanBuilderWithRemoteParent(spanName, spanContext);

相关文章