ErrorParser extends Tag<Throwable> { protected final void tag(Object span, String key, String message) { if (span instanceof SpanCustomizer) { ((SpanCustomizer) span).tag(key, message); } else if (span instanceof MutableSpan) { ((MutableSpan) span).tag(key, message); } else if (span instanceof KeyValueAdapter) { KeyValueAdapter keyValueAdapter = (KeyValueAdapter) span; keyValueAdapter.key = key; keyValueAdapter.value = message; } } ErrorParser(); final void error(Throwable error, SpanCustomizer customizer); final void error(Throwable error, MutableSpan span); static final ErrorParser NOOP; }
@Test public void error_customizer_asTag() { parser.tag(new RuntimeException("this cake is a lie"), customizer); verify(customizer).tag("error", "this cake is a lie"); }
@Test public void subclass_asTag() { subclassErrorParser.tag(new RuntimeException("this cake is a lie"), customizer); verify(customizer).tag("noterror", "the cake is fine"); }