Java Code Examples for brave.handler.MutableSpan#error()

The following examples show how to use brave.handler.MutableSpan#error() . 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: TraceFilterWebIntegrationTests.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: ConvertingSpanReporterTest.java    From zipkin-reporter-java with Apache License 2.0 5 votes vote down vote up
@Test public void doesntOverwriteErrorTag() {
  MutableSpan span = new MutableSpan(context, null);

  span.error(ERROR);
  span.tag("error", "");

  spanReporter.report(span);

  assertThat(spans.get(0).tags())
      .containsOnly(entry("error", ""));
}
 
Example 3
Source File: ConvertingSpanReporter.java    From zipkin-reporter-java with Apache License 2.0 4 votes vote down vote up
void maybeAddErrorTag(MutableSpan span) {
  // span.tag(key) iterates: check if we need to first!
  if (span.error() == null) return;
  if (span.tag("error") == null) errorTag.tag(span.error(), null, span);
}
 
Example 4
Source File: ConvertingSpanReporterTest.java    From zipkin-reporter-java with Apache License 2.0 3 votes vote down vote up
@Test public void backfillsErrorTag() {
  MutableSpan span = new MutableSpan(context, null);

  span.error(ERROR);

  spanReporter.report(span);

  assertThat(spans.get(0).tags())
      .containsOnly(entry("error", "RuntimeException"));
}