本文整理了Java中zipkin2.Span.shared()
方法的一些代码示例,展示了Span.shared()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Span.shared()
方法的具体详情如下:
包路径:zipkin2.Span
类名称:Span
方法名:shared
[英]True if we are contributing to a span started by another tracer (ex on a different host). Defaults to null. When set, it is expected for #kind() to be Kind#SERVER.
When an RPC trace is client-originated, it will be sampled and the same span ID is used for the server side. However, the server shouldn't set span.timestamp or duration since it didn't start the span.
[中]如果我们对由另一个跟踪程序(例如,在另一个主机上)启动的跨度作出贡献,则为True。默认为空。设置后,#kind()应该是#服务器。
当RPC跟踪源于客户端时,将对其进行采样,并对服务器端使用相同的span ID。然而,服务器不应该设置span。时间戳或持续时间,因为它没有开始跨度。
代码示例来源:origin: io.zipkin.zipkin2/zipkin
static int compareShared(Span left, Span right) {
// If either are shared put it last
boolean leftShared = Boolean.TRUE.equals(left.shared());
boolean rightShared = Boolean.TRUE.equals(right.shared());
if (leftShared && rightShared) return 0; // both are shared, so skip out
if (leftShared) return 1;
if (rightShared) return -1;
// neither are shared, put the client spans first
boolean leftClient = Span.Kind.CLIENT.equals(left.kind());
boolean rightClient = Span.Kind.CLIENT.equals(right.kind());
if (leftClient && rightClient) return 0;
if (leftClient) return -1;
if (rightClient) return 1;
return 0; // neither are client spans
}
代码示例来源:origin: io.zipkin.zipkin2/zipkin
/**
* We index spans by (id, shared, localEndpoint) before processing them. This latter fields
* (shared, endpoint) are important because in zipkin (specifically B3), a server can share
* (re-use) the same ID as its client. This impacts processing quite a bit when multiple servers
* share one span ID.
*
* <p>In a Zipkin trace, a parent (client) and child (server) can share the same ID if in an
* RPC. If two different servers respond to the same client, the only way for us to tell which
* is which is by endpoint. Our goal is to retain full paths across multiple endpoints. Even
* though instrumentation should be configured in such a way that a client never sends the same
* span ID to multiple servers, it can happen. Accordingly, we index defensively including any
* endpoint data that might be available.
*/
void index(Span span) {
Object idKey, parentKey;
if (Boolean.TRUE.equals(span.shared())) {
// we need to classify a shared span by its endpoint in case multiple servers respond to the
// same ID sent by the client.
idKey = createKey(span.id(), true, span.localEndpoint());
// the parent of a server span is a client, which is not ambiguous for a given span ID.
parentKey = span.id();
} else {
idKey = span.id();
parentKey = span.parentId();
}
spanToParent.put(idKey, parentKey);
}
代码示例来源:origin: io.zipkin.zipkin2/zipkin
boolean shared = Boolean.TRUE.equals(span.shared());
Object key = createKey(span.id(), shared, span.localEndpoint());
Object noEndpointKey = endpoint != null ? createKey(span.id(), shared, null) : key;
代码示例来源:origin: io.zipkin.zipkin2/zipkin
Span span = result.get(i);
boolean spanShared = Boolean.TRUE.equals(span.shared());
boolean nextShared = Boolean.TRUE.equals(next.shared());
if (spanShared == nextShared && localEndpoint.tryMerge(next.localEndpoint())) {
if (replacement == null) replacement = span.toBuilder();
代码示例来源:origin: io.zipkin.zipkin2/zipkin-storage-cassandra
Input newInput(zipkin2.Span span, UUID ts_uuid) {
boolean traceIdHigh = !strictTraceId && span.traceId().length() == 32;
List<AnnotationUDT> annotations;
if (!span.annotations().isEmpty()) {
annotations =
span.annotations().stream().map(AnnotationUDT::new).collect(Collectors.toList());
} else {
annotations = Collections.emptyList();
}
String annotation_query = searchEnabled ? CassandraUtil.annotationQuery(span) : null;
return new AutoValue_InsertSpan_Input(
ts_uuid,
traceIdHigh ? span.traceId().substring(0, 16) : null,
traceIdHigh ? span.traceId().substring(16) : span.traceId(),
span.parentId(),
span.id(),
span.kind() != null ? span.kind().name() : null,
span.name(),
span.timestampAsLong(),
span.durationAsLong(),
span.localEndpoint() != null ? new EndpointUDT(span.localEndpoint()) : null,
span.remoteEndpoint() != null ? new EndpointUDT(span.remoteEndpoint()) : null,
annotations,
span.tags(),
annotation_query,
Boolean.TRUE.equals(span.debug()),
Boolean.TRUE.equals(span.shared()));
}
代码示例来源:origin: io.zipkin.zipkin2/zipkin
@Override int sizeOfValue(Span span) {
int sizeOfSpan = TRACE_ID.sizeInBytes(span.traceId());
sizeOfSpan += PARENT_ID.sizeInBytes(span.parentId());
sizeOfSpan += ID.sizeInBytes(span.id());
sizeOfSpan += KIND.sizeInBytes(span.kind() != null ? 1 : 0);
sizeOfSpan += NAME.sizeInBytes(span.name());
sizeOfSpan += TIMESTAMP.sizeInBytes(span.timestampAsLong());
sizeOfSpan += DURATION.sizeInBytes(span.durationAsLong());
sizeOfSpan += LOCAL_ENDPOINT.sizeInBytes(span.localEndpoint());
sizeOfSpan += REMOTE_ENDPOINT.sizeInBytes(span.remoteEndpoint());
List<Annotation> annotations = span.annotations();
int annotationCount = annotations.size();
for (int i = 0; i < annotationCount; i++) {
sizeOfSpan += ANNOTATION.sizeInBytes(annotations.get(i));
}
Map<String, String> tags = span.tags();
int tagCount = tags.size();
if (tagCount > 0) { // avoid allocating an iterator when empty
for (Map.Entry<String, String> entry : tags.entrySet()) {
sizeOfSpan += TAG.sizeInBytes(entry);
}
}
sizeOfSpan += DEBUG.sizeInBytes(Boolean.TRUE.equals(span.debug()));
sizeOfSpan += SHARED.sizeInBytes(Boolean.TRUE.equals(span.shared()));
return sizeOfSpan;
}
代码示例来源:origin: io.zipkin.zipkin2/zipkin
@Override void writeValue(Buffer b, Span value) {
TRACE_ID.write(b, value.traceId());
PARENT_ID.write(b, value.parentId());
ID.write(b, value.id());
KIND.write(b, toByte(value.kind()));
NAME.write(b, value.name());
TIMESTAMP.write(b, value.timestampAsLong());
DURATION.write(b, value.durationAsLong());
LOCAL_ENDPOINT.write(b, value.localEndpoint());
REMOTE_ENDPOINT.write(b, value.remoteEndpoint());
List<Annotation> annotations = value.annotations();
int annotationLength = annotations.size();
for (int i = 0; i < annotationLength; i++) {
ANNOTATION.write(b, annotations.get(i));
}
Map<String, String> tags = value.tags();
if (!tags.isEmpty()) { // avoid allocating an iterator when empty
for (Map.Entry<String, String> entry : tags.entrySet()) {
TAG.write(b, entry);
}
}
SpanField.DEBUG.write(b, Boolean.TRUE.equals(value.debug()));
SpanField.SHARED.write(b, Boolean.TRUE.equals(value.shared()));
}
代码示例来源:origin: io.zipkin.zipkin2/zipkin
sizeInBytes += 13; // ,"debug":true
if (Boolean.TRUE.equals(value.shared())) {
sizeInBytes += 14; // ,"shared":true
代码示例来源:origin: io.zipkin.zipkin2/zipkin
if (!Boolean.TRUE.equals(value.shared())) {
result.timestamp(value.timestampAsLong());
result.duration(value.durationAsLong());
代码示例来源:origin: com.google.cloud.trace.adapters.zipkin/translation
if (Boolean.TRUE.equals(zipkinSpan.shared())) {
代码示例来源:origin: io.zipkin.zipkin2/zipkin
b.writeAscii(",\"debug\":true");
if (Boolean.TRUE.equals(value.shared())) {
b.writeAscii(",\"shared\":true");
代码示例来源:origin: io.zipkin.brave/brave-core
if (Boolean.TRUE.equals(in.shared()) && sr != null) {
result.timestamp(null).duration(null);
代码示例来源:origin: io.netifi.proteus/proteus-tracing-openzipkin
private zipkin2.proto3.Span mapSpan(Span span) {
zipkin2.proto3.Span.Builder builder =
zipkin2.proto3.Span.newBuilder().setName(span.name()).setTraceId(span.traceId());
if (span.parentId() != null) {
builder.setParentId(span.parentId());
}
builder.setId(span.id());
if (span.kind() != null) {
builder.setKind(zipkin2.proto3.Span.Kind.valueOf(span.kind().name()));
}
builder.setTimestamp(span.timestampAsLong()).setDuration(span.durationAsLong());
if (span.localEndpoint() != null) {
builder.setLocalEndpoint(mapEndpoint(span.localEndpoint()));
}
if (span.remoteEndpoint() != null) {
builder.setRemoteEndpoint(mapEndpoint(span.remoteEndpoint()));
}
for (Annotation annotation : span.annotations()) {
builder.addAnnotations(mapAnnotation(annotation));
}
builder
.putAllTags(span.tags())
.setDebug(span.debug() == null ? false : span.debug())
.setShared(span.shared() == null ? false : span.shared())
.putTags("group", group)
.putTags("destination", destination);
return builder.build();
}
代码示例来源:origin: io.netifi.proteus/tracing-openzipkin
private zipkin2.proto3.Span mapSpan(Span span) {
zipkin2.proto3.Span.Builder builder =
zipkin2.proto3.Span.newBuilder().setName(span.name()).setTraceId(span.traceId());
if (span.parentId() != null) {
builder.setParentId(span.parentId());
}
builder.setId(span.id());
if (span.kind() != null) {
builder.setKind(zipkin2.proto3.Span.Kind.valueOf(span.kind().name()));
}
builder.setTimestamp(span.timestampAsLong()).setDuration(span.durationAsLong());
if (span.localEndpoint() != null) {
builder.setLocalEndpoint(mapEndpoint(span.localEndpoint()));
}
if (span.remoteEndpoint() != null) {
builder.setRemoteEndpoint(mapEndpoint(span.remoteEndpoint()));
}
for (Annotation annotation : span.annotations()) {
builder.addAnnotations(mapAnnotation(annotation));
}
builder
.putAllTags(span.tags())
.setDebug(span.debug() == null ? false : span.debug())
.setShared(span.shared() == null ? false : span.shared())
.putTags("group", group)
.putTags("destination", destination);
return builder.build();
}
代码示例来源:origin: netifi-proteus/proteus-java
private zipkin2.proto3.Span mapSpan(Span span) {
zipkin2.proto3.Span.Builder builder =
zipkin2.proto3.Span.newBuilder().setName(span.name()).setTraceId(span.traceId());
if (span.parentId() != null) {
builder.setParentId(span.parentId());
}
builder.setId(span.id());
if (span.kind() != null) {
builder.setKind(zipkin2.proto3.Span.Kind.valueOf(span.kind().name()));
}
builder.setTimestamp(span.timestampAsLong()).setDuration(span.durationAsLong());
if (span.localEndpoint() != null) {
builder.setLocalEndpoint(mapEndpoint(span.localEndpoint()));
}
if (span.remoteEndpoint() != null) {
builder.setRemoteEndpoint(mapEndpoint(span.remoteEndpoint()));
}
for (Annotation annotation : span.annotations()) {
builder.addAnnotations(mapAnnotation(annotation));
}
builder
.putAllTags(span.tags())
.setDebug(span.debug() == null ? false : span.debug())
.setShared(span.shared() == null ? false : span.shared())
.putTags("group", group)
.putTags("destination", destination);
return builder.build();
}
代码示例来源:origin: io.github.scouter-project/zipkin-storage-scouter-udp
Boolean spanShared = span.shared();
pack.debug = spanDebug != null ? spanDebug : false;
pack.shared = spanShared != null ? spanShared : false;
内容来源于网络,如有侵权,请联系作者删除!