热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

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

本文整理了Java中brave.propagation.TraceContext.spanId()方法的一些代码示例,展示了TraceContext.spa

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

TraceContext.spanId介绍

[英]Unique 8-byte identifier of this span within a trace.

A span is uniquely identified in storage by ( #traceId, #spanId).
[中]跟踪中此跨度的唯一8字节标识符。
span在存储器中由(#traceId,#spanId)唯一标识。

代码示例

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

RealKey(TraceContext context, ReferenceQueue 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

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

/** Resolves hash code collisions */
@Override public boolean equals(Object other) {
RealKey that = (RealKey) other;
TraceContext thatCOntext= that.get();
if (thatCOntext== null) return false;
return (traceIdHigh == thatContext.traceIdHigh())
&& (traceId == thatContext.traceId())
&& (spanId == thatContext.spanId())
&& shared == thatContext.shared();
}
}

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

void set(TraceContext context) {
set(context.traceIdHigh(), context.traceId(), context.spanId(), context.shared());
}

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

/** Trace contexts are equal only on trace ID and span ID. try to get the parent's clock */
@Nullable TickClock getClockFromParent(TraceContext context) {
long parentId = context.parentIdAsLong();
// NOTE: we still look for lookup key even on root span, as a client span can be root, and a
// server can share the same ID. Essentially, a shared span is similar to a child.
PendingSpan parent = null;
if (context.shared() || parentId != 0L) {
long spanId = parentId != 0L ? parentId : context.spanId();
parent = delegate.get(InternalPropagation.instance.newTraceContext(
0,
context.traceIdHigh(),
context.traceId(),
0,
0,
spanId,
Collections.emptyList()
));
}
return parent != null ? parent.clock : null;
}

代码示例来源: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: spring-cloud/spring-cloud-sleuth

replace("parentId", parentId);
replace(LEGACY_PARENT_ID_NAME, parentId);
String spanId = HexCodec.toLowerHex(currentSpan.spanId());
MDC.put("spanId", spanId);
MDC.put(LEGACY_SPAN_ID_NAME, spanId);

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

public final TraceContext decorate(TraceContext context) {
long traceId = context.traceId(), spanId = context.spanId();
Class type = type();

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

replace("parentId", parentId);
replace(LEGACY_PARENT_ID_NAME, parentId);
String spanId = HexCodec.toLowerHex(currentSpan.spanId());
MDC.put("spanId", spanId);
MDC.put(LEGACY_SPAN_ID_NAME, spanId);

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

/**
* Called by methods which can accept externally supplied parent trace contexts: Ex. {@link
* #newChild(TraceContext)} and {@link #startScopedSpanWithParent(String, TraceContext)}. This
* implies the {@link TraceContext#localRootId()} could be zero, if the context was manually
* created.
*/
TraceContext nextContext(TraceContext parent) {
return nextContext(
InternalPropagation.instance.flags(parent),
parent.traceIdHigh(),
parent.traceId(),
parent.localRootId(),
parent.spanId(),
parent.extra()
);
}

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

context.traceIdHigh(),
context.traceId(),
context.spanId(), // local root
context.parentIdAsLong(),
context.spanId(),
context.extra()
);

代码示例来源: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: openzipkin/brave

traceId = implicitParent.traceId();
localRootId = implicitParent.localRootId();
spanId = implicitParent.spanId();
extra = concatImmutableLists(extra, implicitParent.extra());
} else {

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

RealKey(TraceContext context, ReferenceQueue 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-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: io.zipkin.brave/brave

/** Resolves hash code collisions */
@Override public boolean equals(Object other) {
RealKey that = (RealKey) other;
TraceContext thatCOntext= that.get();
if (thatCOntext== null) return false;
return (traceIdHigh == thatContext.traceIdHigh())
&& (traceId == thatContext.traceId())
&& (spanId == thatContext.spanId())
&& shared == thatContext.shared();
}
}

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

void set(TraceContext context) {
set(context.traceIdHigh(), context.traceId(), context.spanId(), context.shared());
}

代码示例来源: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-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();
}
}

代码示例来源:origin: xjdr/xio

Tracing.Builder tracingBuilder(Sampler sampler) {
return Tracing.newBuilder()
.spanReporter(
s -> {
// make sure the context was cleared prior to finish.. no leaks!
TraceContext current = httpTracing.tracing().currentTraceContext().get();
if (current != null) {
Assert.assertNotEquals(current.spanId(), s.id());
}
spans.add(s);
})
.currentTraceContext(currentTraceContext)
.sampler(sampler);
}

推荐阅读
author-avatar
闺蜜好我会明白
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有