zipkin2.Span.localEndpoint()方法的使用及代码示例

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

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

Span.localEndpoint介绍

[英]The host that recorded this span, primarily for query by service name.

Instrumentation should always record this and be consistent as possible with the service name as it is used in search. This is nullable for legacy reasons.
[中]记录此跨度的主机,主要用于按服务名称进行查询。
检测应始终记录这一点,并尽可能与搜索中使用的服务名称保持一致。由于遗留原因,该值可以为空。

代码示例

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

@Nullable public String localServiceName() {
 Endpoint localEndpoint = localEndpoint();
 return localEndpoint != null ? localEndpoint.serviceName() : null;
}

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

@Override public int compare(Span left, Span right) {
  if (left.equals(right)) return 0;
  int bySpanId = left.id().compareTo(right.id());
  if (bySpanId != 0) return bySpanId;
  int byShared = compareShared(left, right);
  if (byShared != 0) return byShared;
  return compareEndpoint(left.localEndpoint(), right.localEndpoint());
 }
};

代码示例来源:origin: com.google.cloud.trace.adapters.zipkin/translation

if (zipkinSpan.localEndpoint() != null && zipkinSpan.kind() == Span.Kind.SERVER) {
 if (zipkinSpan.localEndpoint().ipv4() != null) {
  result.put(getLabelName("endpoint.ipv4"), zipkinSpan.localEndpoint().ipv4());
 if (zipkinSpan.localEndpoint().ipv6() != null) {
  result.put(getLabelName("endpoint.ipv6"), zipkinSpan.localEndpoint().ipv6());
if (zipkinSpan.localEndpoint() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) {
 result.put(kComponentLabelKey, zipkinSpan.localEndpoint().serviceName());

代码示例来源: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.github.scouter-project/zipkin-storage-scouter-udp

public static void registerZipkinObj(Span span, ScouterConfig conf) {
  String objName = ScouterConstants.toScouterObjName(span.localServiceName());
  int objHash = HashUtil.hash(objName);
  long registered = objSentMap.get(objHash);
  long now = System.currentTimeMillis();
  if (registered != 0 && now - registered < 30 * 1000) {
    return;
  }
  ObjectPack p = new ObjectPack();
  p.objType = ScouterConstants.toScouterObjType(span.localServiceName(), conf);
  p.objName = objName;
  p.objHash = objHash;
  if (span.localEndpoint() != null) {
    p.address = span.localEndpoint().ipv4() + ":" + span.localEndpoint().portAsInt();
  }
  p.tags.put(scouter.lang.constants.ScouterConstants.TAG_OBJ_DETECTED_TYPE, "zipkin");
  p.tags.put(ObjectPack.TAG_KEY_DEAD_TIME, 300 * 1000);
  objSentMap.put(objHash, now);
  sendHeartBeat(p);
  if (conf.isDebug()) {
    logger.info("Object heartbeat: " + p);
  }
}

代码示例来源:origin: openzipkin/zipkin-gcp

if (zipkinSpan.localEndpoint() != null && zipkinSpan.kind() == Span.Kind.SERVER) {
 if (zipkinSpan.localEndpoint().ipv4() != null) {
  attributes.putAttributeMap(
    getLabelName("endpoint.ipv4"), toAttributeValue(zipkinSpan.localEndpoint().ipv4()));
 if (zipkinSpan.localEndpoint().ipv6() != null) {
  attributes.putAttributeMap(
    getLabelName("endpoint.ipv6"), toAttributeValue(zipkinSpan.localEndpoint().ipv6()));
if (zipkinSpan.localEndpoint() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) {
 attributes.putAttributeMap(
   kComponentLabelKey, toAttributeValue(zipkinSpan.localEndpoint().serviceName()));

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

Endpoint endpoint = span.localEndpoint();
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-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

localEndpoint.tryMerge(span.localEndpoint());
if (spanShared == nextShared && localEndpoint.tryMerge(next.localEndpoint())) {
 if (replacement == null) replacement = span.toBuilder();
 replacement.merge(next);

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

value.localEndpoint() != null ? ThriftEndpointCodec.sizeInBytes(value.localEndpoint()) : 0;

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

Endpoint ep = value.localEndpoint();
int annotationCount = value.annotations().size();
if (beginAnnotation) {

代码示例来源:origin: Nike-Inc/wingtips

assertThat(zipkinSpan.traceId()).isEqualTo(wingtipsSpan.getTraceId());
assertThat(zipkinSpan.duration()).isEqualTo(durationMicros);
assertThat(zipkinSpan.localEndpoint()).isEqualTo(zipkinEndpoint);
assertThat(zipkinSpan.tags()).isEqualTo(wingtipsSpan.getTags()).isEmpty();
assertThat(zipkinSpan.annotations()).isEqualTo(wingtipsSpan.getTimestampedAnnotations()).isEmpty();

代码示例来源:origin: Nike-Inc/wingtips

assertThat(zipkinSpan.traceId()).isEqualTo(wingtipsSpan.getTraceId());
assertThat(zipkinSpan.duration()).isEqualTo(durationMicros);
assertThat(zipkinSpan.localEndpoint()).isEqualTo(zipkinEndpoint);
assertThat(zipkinSpan.tags()).isEqualTo(wingtipsSpan.getTags());
assertThat(toWingtipsAnnotations(zipkinSpan.annotations())).isEqualTo(wingtipsSpan.getTimestampedAnnotations());

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

b.writeAscii(",\"duration\":").writeAscii(value.durationAsLong());
if (value.localEndpoint() != null) {
 b.writeAscii(",\"localEndpoint\":");
 writeEndpoint(value.localEndpoint(), b, false);

代码示例来源: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.zipkin.zipkin2/zipkin

@Override
public void write(Span value, Buffer buffer) {
 V1Span v1Span = converter.convert(value);
 byte[] endpointBytes = legacyEndpointBytes(value.localEndpoint());

相关文章