Java Code Examples for brave.handler.MutableSpan#kind()
The following examples show how to use
brave.handler.MutableSpan#kind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MutableSpanBenchmarks.java From zipkin-reporter-java with Apache License 2.0 | 6 votes |
public static MutableSpan newBigClientSpan() { MutableSpan span = new MutableSpan(); span.name("getuserinfobyaccesstoken"); span.kind(Span.Kind.CLIENT); span.remoteServiceName("abasdasgad.hsadas.ism"); span.remoteIpAndPort("219.235.216.11", 0); span.startTimestamp(1533706251750057L); span.finishTimestamp(1533706251935296L); span.tag("address.local", "/10.1.2.3:59618"); span.tag("address.remote", "abasdasgad.hsadas.ism/219.235.216.11:8080"); span.tag("http.host", "abasdasgad.hsadas.ism"); span.tag("http.method", "POST"); span.tag("http.path", "/thrift/shopForTalk"); span.tag("http.status_code", "200"); span.tag("http.url", "tbinary+h2c://abasdasgad.hsadas.ism/thrift/shopForTalk"); span.tag("instanceId", "line-wallet-api"); span.tag("phase", "beta"); span.tag("siteId", "shop"); return span; }
Example 2
Source File: ConvertingSpanReporterTest.java From zipkin-reporter-java with Apache License 2.0 | 6 votes |
@Test public void remoteEndpoint() { MutableSpan span = new MutableSpan(context, null); Endpoint endpoint = Endpoint.newBuilder() .serviceName("fooService") .ip("1.2.3.4") .port(80) .build(); span.kind(CLIENT); span.remoteServiceName(endpoint.serviceName()); span.remoteIpAndPort(endpoint.ipv4(), endpoint.port()); span.startTimestamp(1L); span.finishTimestamp(2L); spanReporter.report(span); assertThat(spans.get(0).remoteEndpoint()) .isEqualTo(endpoint); }
Example 3
Source File: TraceFilterWebIntegrationTests.java From spring-cloud-sleuth with Apache License 2.0 | 6 votes |
@Bean SpanHandler uncaughtExceptionThrown(CurrentTraceContext currentTraceContext) { return new SpanHandler() { @Override public boolean end(TraceContext context, MutableSpan span, Cause cause) { if (span.kind() != Kind.SERVER || span.error() == null || !log.isErrorEnabled()) { return true; // don't add overhead as we only log server errors } // In TracingFilter, the exception is raised in scope. This is is more // explicit to ensure it works in other tech such as WebFlux. try (Scope scope = currentTraceContext.maybeScope(context)) { log.error("Uncaught exception thrown", span.error()); } return true; } @Override public String toString() { return "UncaughtExceptionThrown"; } }; }
Example 4
Source File: MutableSpanBenchmarks.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
public static MutableSpan newServerSpan() { MutableSpan span = new MutableSpan(); span.name("get /"); span.kind(Span.Kind.SERVER); span.remoteIpAndPort("::1", 63596); span.startTimestamp(1533706251750057L); span.finishTimestamp(1533706251935296L); span.tag("http.method", "GET"); span.tag("http.path", "/"); span.tag("mvc.controller.class", "Frontend"); span.tag("mvc.controller.method", "callBackend"); return span; }
Example 5
Source File: ConvertingSpanReporterTest.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
void finish(brave.Span.Kind braveKind, Span.Kind span2Kind) { MutableSpan span = new MutableSpan(context, null); span.kind(braveKind); span.startTimestamp(1L); span.finishTimestamp(2L); spanReporter.report(span); Span zipkinSpan = spans.get(0); assertThat(zipkinSpan.annotations()).isEmpty(); assertThat(zipkinSpan.timestamp()).isEqualTo(1L); assertThat(zipkinSpan.duration()).isEqualTo(1L); assertThat(zipkinSpan.kind()).isEqualTo(span2Kind); }
Example 6
Source File: ConvertingSpanReporterTest.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
void flush(brave.Span.Kind braveKind, Span.Kind span2Kind) { MutableSpan span = new MutableSpan(context, null); span.kind(braveKind); span.startTimestamp(1L); span.finishTimestamp(0L); spanReporter.report(span); Span zipkinSpan = spans.get(0); assertThat(zipkinSpan.annotations()).isEmpty(); assertThat(zipkinSpan.timestamp()).isEqualTo(1L); assertThat(zipkinSpan.duration()).isNull(); assertThat(zipkinSpan.kind()).isEqualTo(span2Kind); }
Example 7
Source File: ConvertingSpanReporterTest.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
@Test public void writeTo_sharedStatus() { MutableSpan span = new MutableSpan(context, null); span.setShared(); span.startTimestamp(1L); span.kind(SERVER); span.finishTimestamp(2L); spanReporter.report(span); assertThat(spans.get(0).shared()) .isTrue(); }
Example 8
Source File: SkeletalSpansTest.java From brave with Apache License 2.0 | 5 votes |
@Override public boolean end(TraceContext context, MutableSpan span, Cause cause) { if (span.kind() == null) return false; // skip local spans if (!context.isLocalRoot()) { span.parentId(context.localRootIdString()); // rewrite the parent ID } span.forEachAnnotation((timestamp, value) -> null); // drop all annotations span.forEachTag((key, value) -> { if (key.equals("error")) return ""; // linking counts errors: the value isn't important return null; }); span.remoteIp(null); // retain only the service name span.remotePort(0); return true; }
Example 9
Source File: ConvertingSpanReporter.java From zipkin-reporter-java with Apache License 2.0 | 4 votes |
static Span convert(MutableSpan span) { Span.Builder result = Span.newBuilder() .traceId(span.traceId()) .parentId(span.parentId()) .id(span.id()) .name(span.name()); long start = span.startTimestamp(), finish = span.finishTimestamp(); result.timestamp(start); if (start != 0 && finish != 0L) result.duration(Math.max(finish - start, 1)); // use ordinal comparison to defend against version skew Kind kind = span.kind(); if (kind != null) { result.kind(BRAVE_TO_ZIPKIN_KIND.get(kind)); } String localServiceName = span.localServiceName(), localIp = span.localIp(); if (localServiceName != null || localIp != null) { result.localEndpoint(Endpoint.newBuilder() .serviceName(localServiceName) .ip(localIp) .port(span.localPort()) .build()); } String remoteServiceName = span.remoteServiceName(), remoteIp = span.remoteIp(); if (remoteServiceName != null || remoteIp != null) { result.remoteEndpoint(Endpoint.newBuilder() .serviceName(remoteServiceName) .ip(remoteIp) .port(span.remotePort()) .build()); } span.forEachTag(Consumer.INSTANCE, result); span.forEachAnnotation(Consumer.INSTANCE, result); if (span.shared()) result.shared(true); if (span.debug()) result.debug(true); return result.build(); }