本文整理了Java中brave.propagation.TraceContext.sampled()
方法的一些代码示例,展示了TraceContext.sampled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TraceContext.sampled()
方法的具体详情如下:
包路径:brave.propagation.TraceContext
类名称:TraceContext
方法名:sampled
暂无
代码示例来源:origin: stagemonitor/stagemonitor
@Override
public boolean isSampled(Span span) {
// TODO replace with Span#unwrap once https://github.com/opentracing/opentracing-java/pull/211 is merged
if (span instanceof SpanWrapper) {
span = ((SpanWrapper) span).getDelegate();
}
if (span instanceof BraveSpan) {
final BraveSpan braveSpan = (BraveSpan) span;
return braveSpan.unwrap().context().sampled();
}
return false;
}
代码示例来源:origin: openzipkin/brave
static byte[] toBytes(TraceContext traceContext) {
checkNotNull(traceContext, "traceContext");
byte[] bytes = new byte[FORMAT_LENGTH];
bytes[0] = VERSION;
bytes[1] = TRACE_ID_FIELD_ID;
writeLong(bytes, 2, traceContext.traceIdHigh());
writeLong(bytes, 10, traceContext.traceId());
bytes[18] = SPAN_ID_FIELD_ID;
writeLong(bytes, 19, traceContext.spanId());
bytes[27] = TRACE_OPTION_FIELD_ID;
if (traceContext.sampled() != null && traceContext.sampled()) {
bytes[28] = 1;
}
return bytes;
}
代码示例来源:origin: openzipkin/brave
RealKey(TraceContext context, ReferenceQueue<TraceContext> queue) {
super(context, queue);
hashCode = context.hashCode();
traceIdHigh = context.traceIdHigh();
traceId = context.traceId();
localRootId = context.localRootId();
spanId = context.spanId();
sampled = Boolean.TRUE.equals(context.sampled());
}
代码示例来源:origin: openzipkin/brave
@Override public void inject(TraceContext traceContext, C carrier) {
setter.put(carrier, propagation.traceIdKey, traceContext.traceIdString());
setter.put(carrier, propagation.spanIdKey, traceContext.spanIdString());
String parentId = traceContext.parentIdString();
if (parentId != null) {
setter.put(carrier, propagation.parentSpanIdKey, parentId);
}
if (traceContext.debug()) {
setter.put(carrier, propagation.debugKey, "1");
} else if (traceContext.sampled() != null) {
setter.put(carrier, propagation.sampledKey, traceContext.sampled() ? "1" : "0");
}
}
}
代码示例来源:origin: spring-cloud/spring-cloud-sleuth
MDC.put("spanId", spanId);
MDC.put(LEGACY_SPAN_ID_NAME, spanId);
String sampled = String.valueOf(currentSpan.sampled());
MDC.put("spanExportable", sampled);
MDC.put(LEGACY_EXPORTABLE_NAME, sampled);
代码示例来源:origin: spring-cloud/spring-cloud-sleuth
MDC.put("spanId", spanId);
MDC.put(LEGACY_SPAN_ID_NAME, spanId);
String sampled = String.valueOf(currentSpan.sampled());
MDC.put("spanExportable", sampled);
MDC.put(LEGACY_EXPORTABLE_NAME, sampled);
代码示例来源:origin: openzipkin/brave
@Override public boolean handle(TraceContext context, MutableSpan span) {
if (!Boolean.TRUE.equals(context.sampled())) return true;
Span.Builder builderWithContextData = Span.newBuilder()
.traceId(context.traceIdString())
.parentId(context.parentIdString())
.id(context.spanIdString());
if (context.debug()) builderWithContextData.debug(true);
converter.convert(span, builderWithContextData);
spanReporter.report(builderWithContextData.build());
return true;
}
代码示例来源:origin: openzipkin/brave
static int writeB3SingleFormat(TraceContext context, long parentId, char[] result) {
int pos = 0;
long traceIdHigh = context.traceIdHigh();
if (traceIdHigh != 0L) {
writeHexLong(result, pos, traceIdHigh);
pos += 16;
}
writeHexLong(result, pos, context.traceId());
pos += 16;
result[pos++] = '-';
writeHexLong(result, pos, context.spanId());
pos += 16;
Boolean sampled = context.sampled();
if (sampled != null) {
result[pos++] = '-';
result[pos++] = context.debug() ? 'd' : sampled ? '1' : '0';
}
if (parentId != 0L) {
result[pos++] = '-';
writeHexLong(result, pos, parentId);
pos += 16;
}
return pos;
}
代码示例来源:origin: io.zipkin.brave/brave-instrumentation-grpc
static byte[] toBytes(TraceContext traceContext) {
checkNotNull(traceContext, "traceContext");
byte[] bytes = new byte[FORMAT_LENGTH];
bytes[0] = VERSION;
bytes[1] = TRACE_ID_FIELD_ID;
writeLong(bytes, 2, traceContext.traceIdHigh());
writeLong(bytes, 10, traceContext.traceId());
bytes[18] = SPAN_ID_FIELD_ID;
writeLong(bytes, 19, traceContext.spanId());
bytes[27] = TRACE_OPTION_FIELD_ID;
if (traceContext.sampled() != null && traceContext.sampled()) {
bytes[28] = 1;
}
return bytes;
}
代码示例来源:origin: io.zipkin.brave/brave-propagation-aws
writeHexLong(result, 48, traceContext.spanId());
System.arraycopy(SAMPLED, 0, result, 64, 9);
Boolean sampled = traceContext.sampled();
代码示例来源:origin: io.zipkin.brave/brave
RealKey(TraceContext context, ReferenceQueue<TraceContext> queue) {
super(context, queue);
hashCode = context.hashCode();
traceIdHigh = context.traceIdHigh();
traceId = context.traceId();
localRootId = context.localRootId();
spanId = context.spanId();
sampled = Boolean.TRUE.equals(context.sampled());
}
代码示例来源:origin: io.zipkin.brave/brave
@Override public void inject(TraceContext traceContext, C carrier) {
setter.put(carrier, propagation.traceIdKey, traceContext.traceIdString());
setter.put(carrier, propagation.spanIdKey, traceContext.spanIdString());
String parentId = traceContext.parentIdString();
if (parentId != null) {
setter.put(carrier, propagation.parentSpanIdKey, parentId);
}
if (traceContext.debug()) {
setter.put(carrier, propagation.debugKey, "1");
} else if (traceContext.sampled() != null) {
setter.put(carrier, propagation.sampledKey, traceContext.sampled() ? "1" : "0");
}
}
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core
MDC.put("spanId", spanId);
MDC.put(LEGACY_SPAN_ID_NAME, spanId);
String sampled = String.valueOf(currentSpan.sampled());
MDC.put("spanExportable", sampled);
MDC.put(LEGACY_EXPORTABLE_NAME, sampled);
代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core
MDC.put("spanId", spanId);
MDC.put(LEGACY_SPAN_ID_NAME, spanId);
String sampled = String.valueOf(currentSpan.sampled());
MDC.put("spanExportable", sampled);
MDC.put(LEGACY_EXPORTABLE_NAME, sampled);
代码示例来源:origin: com.github.gitssie/play-transport
public void propagationTraceInfo(HttpUriRequest request, Span span) {
TraceContext currentSpan = span.context();
request.addHeader("X-B3-TraceId",currentSpan.traceIdString());
request.addHeader("X-B3-SpanId", HexCodec.toLowerHex(currentSpan.spanId()));
if(currentSpan.parentId() != null) {
request.addHeader("X-B3-ParentSpanId", HexCodec.toLowerHex(currentSpan.parentId()));
}
request.addHeader("X-B3-Sampled",String.valueOf(currentSpan.sampled()));
}
代码示例来源:origin: io.zipkin.brave/brave
@Override public boolean handle(TraceContext context, MutableSpan span) {
if (!Boolean.TRUE.equals(context.sampled())) return true;
Span.Builder builderWithContextData = Span.newBuilder()
.traceId(context.traceIdString())
.parentId(context.parentIdString())
.id(context.spanIdString());
if (context.debug()) builderWithContextData.debug(true);
converter.convert(span, builderWithContextData);
spanReporter.report(builderWithContextData.build());
return true;
}
代码示例来源:origin: io.zipkin.brave/brave
static int writeB3SingleFormat(TraceContext context, long parentId, char[] result) {
int pos = 0;
long traceIdHigh = context.traceIdHigh();
if (traceIdHigh != 0L) {
writeHexLong(result, pos, traceIdHigh);
pos += 16;
}
writeHexLong(result, pos, context.traceId());
pos += 16;
result[pos++] = '-';
writeHexLong(result, pos, context.spanId());
pos += 16;
Boolean sampled = context.sampled();
if (sampled != null) {
result[pos++] = '-';
result[pos++] = context.debug() ? 'd' : sampled ? '1' : '0';
}
if (parentId != 0L) {
result[pos++] = '-';
writeHexLong(result, pos, parentId);
pos += 16;
}
return pos;
}
代码示例来源:origin: io.zipkin.brave/brave-core
static SpanId toSpanId(TraceContext context) {
return SpanId.builder()
.traceIdHigh(context.traceIdHigh())
.traceId(context.traceId())
.parentId(context.parentId())
.spanId(context.spanId())
.debug(context.debug())
.sampled(context.sampled()).build();
}
}
内容来源于网络,如有侵权,请联系作者删除!