DefaultErrorSpanTagger implements ErrorSpanTagger { @Override public void tagSpanForError(@NotNull Span span, @NotNull Throwable error) { if (span != null && error != null) { span.putTag(KnownZipkinTags.ERROR, error.toString()); } }  @Override void tagSpanForError(@NotNull Span span, @NotNull Throwable error);  }
@DataProvider(value = { "false | false | true", "true | false | false", "false | true | false", "true | true | false", }, splitBy = "\\|") @Test @SuppressWarnings("ConstantConditions") public void tagSpanForError_works_as_expected(boolean spanIsNull, boolean errorIsNull, boolean expectErrorTag) { DefaultErrorSpanTagger tagger = new DefaultErrorSpanTagger(); Span span = (spanIsNull) ? null : mock(Span.class); Throwable error = (errorIsNull) ? null : new Exception("Intentional test exception: " + UUID.randomUUID().toString()); tagger.tagSpanForError(span, error); if (expectErrorTag) { verify(span).putTag(KnownZipkinTags.ERROR, error.toString()); } else if (span != null) { verifyNoInteractions(span); } }