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

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

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

Span.remoteEndpoint介绍

[英]When an RPC (or messaging) span, indicates the other side of the connection.

By recording the remote endpoint, your trace will contain network context even if the peer is not tracing. For example, you can record the IP from the X-Forwarded-For header or the service name and socket of a remote peer.
[中]当RPC(或消息传递)跨越时,表示连接的另一端。
通过记录远程端点,跟踪将包含网络上下文,即使对等方没有跟踪。例如,您可以从X-Forwarded-For报头或远程对等方的服务名称和套接字记录IP。

代码示例

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

@Test
public void reportsClientAddress_XForwardedFor() throws Exception {
 get(new Request.Builder().url(url("/foo"))
   .header("X-Forwarded-For", "1.2.3.4")
   .build());
 Span span = takeSpan();
 assertThat(span.remoteEndpoint())
   .extracting(Endpoint::ipv4)
   .isEqualTo("1.2.3.4");
}

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

@Test
public void reportsClientAddress() throws Exception {
 get("/foo");
 Span span = takeSpan();
 assertThat(span.remoteEndpoint())
   .isNotNull();
}

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

@Test
public void reportsServerAddress() throws Exception {
 server.enqueue(new MockResponse());
 get(client, "/foo");
 Span span = takeSpan();
 assertThat(span.remoteEndpoint())
   .isEqualTo(Endpoint.newBuilder()
     .ip("127.0.0.1")
     .port(server.getPort()).build()
   );
}

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

@Test
public void reportsClientAddress_XForwardedFor() throws Exception {
 String path = "/foo";
 Request request = new Request.Builder().url(url(path))
   .header("X-Forwarded-For", "1.2.3.4")
   .build();
 try (Response response = client.newCall(request).execute()) {
  assertThat(response.isSuccessful()).isTrue();
 }
 assertThat(collectedSpans())
   .extracting(s -> s.remoteEndpoint().ipv4())
   .contains("1.2.3.4");
}

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

@Test
public void reportsClientAddress() throws Exception {
 get("/foo");
 Span span = takeSpan();
 assertThat(span.remoteEndpoint())
   .isNotNull();
}

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

@Test
public void reportsClientAddress_XForwardedFor() throws Exception {
 get(new Request.Builder().url(url("/foo"))
   .header("X-Forwarded-For", "1.2.3.4")
   .build());
 Span span = takeSpan();
 assertThat(span.remoteEndpoint())
   .extracting(Endpoint::ipv4)
   .isEqualTo("1.2.3.4");
}

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

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

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

@Test
public void reportsServerAddress() throws Exception {
 server.enqueue(new MockResponse());
 get(client, "/foo");
 Span span = takeSpan();
 assertThat(span.remoteEndpoint())
   .isEqualTo(Endpoint.newBuilder()
     .ip("127.0.0.1")
     .port(server.getPort()).build()
   );
}

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

if (in.remoteEndpoint() != null) addr = "sa"; // default value
if (in.remoteEndpoint() == null) addr = null;

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

sizeInBytes += endpointSizeInBytes(value.localEndpoint(), false);
if (value.remoteEndpoint() != null) {
 sizeInBytes += 18; // ,"remoteEndpoint":
 sizeInBytes += endpointSizeInBytes(value.remoteEndpoint(), false);

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

boolean hasRemoteEndpoint = md.addr != null && value.remoteEndpoint() != null;
if (hasRemoteEndpoint) result.addBinaryAnnotation(md.addr, value.remoteEndpoint());
return result.build();

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

@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

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

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

zipkin.Endpoint remote = in.remoteEndpoint() != null ? toEndpoint(in.remoteEndpoint()) : null;
Kind kind = in.kind();
Annotation

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

Endpoint remoteEndPoint = span.remoteEndpoint();

相关文章