brave.propagation.TraceContext.toBuilder()方法的使用及代码示例

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

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

TraceContext.toBuilder介绍

暂无

代码示例

代码示例来源:origin: openzipkin/brave

void noticesDifferentSpanId(Scope scope) {
 TraceContext differentSpanId = context.toBuilder().spanId(context.spanId() + 1L).build();
 try (Scope scope2 = currentTraceContext.maybeScope(differentSpanId)) {
  assertThat(scope2).isNotEqualTo(Scope.NOOP);
  assertThat(currentTraceContext.get())
    .isEqualTo(differentSpanId);
  verifyImplicitContext(differentSpanId);
 } finally {
  scope.close();
 }
}

代码示例来源:origin: openzipkin/brave

@Test public void verifyRoundTrip_notSampled() throws Exception {
 inject(map, "0000000000000001", "0000000000000001", "0000000000000002", false, null);
 verifyRoundTrip(TraceContextOrSamplingFlags.create(
   childSpan.toBuilder().sampled(false).build()
 ));
}

代码示例来源:origin: openzipkin/brave

/**
 * When the caller propagates IDs, but not a sampling decision, the current process should
 * decide.
 */
@Test public void verifyRoundTrip_externallyProvidedIds() {
 inject(map, "0000000000000001", null, "0000000000000001", null, null);
 verifyRoundTrip(TraceContextOrSamplingFlags.create(rootSpan.toBuilder().sampled(null).build()));
}

代码示例来源:origin: openzipkin/brave

@Test public void verifyRoundTrip_128BitTrace() throws Exception {
 String high64Bits = "463ac35c9f6413ad";
 String low64Bits = "48485a3953bb6124";
 inject(map, high64Bits + low64Bits, null, low64Bits, true, null);
 verifyRoundTrip(TraceContextOrSamplingFlags.create(rootSpan.toBuilder()
   .traceIdHigh(HexCodec.lowerHexToUnsignedLong(high64Bits))
   .traceId(HexCodec.lowerHexToUnsignedLong(low64Bits))
   .spanId(HexCodec.lowerHexToUnsignedLong(low64Bits)).build()));
}

代码示例来源:origin: io.zipkin.brave/brave-tests

void noticesDifferentSpanId(Scope scope) {
 TraceContext differentSpanId = context.toBuilder().spanId(context.spanId() + 1L).build();
 try (Scope scope2 = currentTraceContext.maybeScope(differentSpanId)) {
  assertThat(scope2).isNotEqualTo(Scope.NOOP);
  assertThat(currentTraceContext.get())
    .isEqualTo(differentSpanId);
  verifyImplicitContext(differentSpanId);
 } finally {
  scope.close();
 }
}

代码示例来源:origin: openzipkin-contrib/brave-opentracing

/**
 * <em>Note:</em>If the key is {@linkplain Tags#SAMPLING_PRIORITY} and the value is zero, the
 * current span will be abandoned and future references to the {@link #context()} will be
 * unsampled. This does not affect the active span, nor does it affect any equivalent instances of
 * this object. This is a best efforts means to handle late sampling decisions.
 */
@Override public BraveSpan setTag(String key, Number value) {
 if (finishCalled) return this;
 if (trySetPeer(key, value)) return this;
 // handle late sampling decision
 if (Tags.SAMPLING_PRIORITY.getKey().equals(key) && value.intValue() == 0) {
  delegate.abandon();
  // convert the span to no-op
  delegate = tracer.toSpan(delegate.context().toBuilder().sampled(false).build());
 }
 return setTag(key, value.toString());
}

代码示例来源:origin: io.zipkin.brave/brave-tests

@Test public void verifyRoundTrip_notSampled() throws Exception {
 inject(map, "0000000000000001", "0000000000000001", "0000000000000002", false, null);
 verifyRoundTrip(TraceContextOrSamplingFlags.create(
   childSpan.toBuilder().sampled(false).build()
 ));
}

代码示例来源:origin: io.zipkin.brave/brave-tests

/**
 * When the caller propagates IDs, but not a sampling decision, the current process should
 * decide.
 */
@Test public void verifyRoundTrip_externallyProvidedIds() {
 inject(map, "0000000000000001", null, "0000000000000001", null, null);
 verifyRoundTrip(TraceContextOrSamplingFlags.create(rootSpan.toBuilder().sampled(null).build()));
}

代码示例来源:origin: io.zipkin.brave/brave-tests

@Test public void verifyRoundTrip_128BitTrace() throws Exception {
 String high64Bits = "463ac35c9f6413ad";
 String low64Bits = "48485a3953bb6124";
 inject(map, high64Bits + low64Bits, null, low64Bits, true, null);
 verifyRoundTrip(TraceContextOrSamplingFlags.create(rootSpan.toBuilder()
   .traceIdHigh(HexCodec.lowerHexToUnsignedLong(high64Bits))
   .traceId(HexCodec.lowerHexToUnsignedLong(low64Bits))
   .spanId(HexCodec.lowerHexToUnsignedLong(low64Bits)).build()));
}

相关文章