use of com.newrelic.agent.model.SpanError in project newrelic-java-agent by newrelic.
the class SpanErrorBuilderTest method shouldBuildEmptySpanErrorWithoutReportableError.
@Test
public void shouldBuildEmptySpanErrorWithoutReportableError() {
when(mockAnalyzer.isReportable(eq(400), ArgumentMatchers.<Throwable>any())).thenReturn(false);
when(mockTracer.getException()).thenReturn(null);
SpanError target = new SpanErrorBuilder(mockAnalyzer, mockReplacer).buildSpanError(mockTracer, true, 200, "fine", null);
assertEmptySpanError(target);
}
use of com.newrelic.agent.model.SpanError in project newrelic-java-agent by newrelic.
the class SpanErrorBuilderTest method shouldBuildEmptySpanErrorWithReportableStatusOnNonRoot.
@Test
public void shouldBuildEmptySpanErrorWithReportableStatusOnNonRoot() {
when(mockAnalyzer.isReportable(eq(400), ArgumentMatchers.<Throwable>any())).thenReturn(true);
when(mockAnalyzer.isReportable(400)).thenReturn(true);
when(mockAnalyzer.isIgnoredError(anyInt(), ArgumentMatchers.<Throwable>any())).thenReturn(false);
when(mockTracer.getException()).thenReturn(null);
SpanError target = new SpanErrorBuilder(mockAnalyzer, mockReplacer).buildSpanError(mockTracer, false, 400, "fine", null);
assertEmptySpanError(target);
}
use of com.newrelic.agent.model.SpanError in project newrelic-java-agent by newrelic.
the class SpanErrorBuilderTest method shouldSetExpectedErrorTrueForSpanErrorOnRootSpan.
@Test
public void shouldSetExpectedErrorTrueForSpanErrorOnRootSpan() {
final String spanGuid = "SPAN_GUID";
TransactionThrowable fakeThrowable = new TransactionThrowable(new IllegalArgumentException("what did I do?"), true, spanGuid);
when(mockTracer.getGuid()).thenReturn(spanGuid);
when(mockTracer.wasExceptionSetByAPI()).thenReturn(true);
when(mockTracer.getException()).thenReturn(fakeThrowable.throwable);
when(mockAnalyzer.isExpectedError(400, fakeThrowable)).thenReturn(true);
when(mockAnalyzer.isReportable(400)).thenReturn(true);
SpanError target = new SpanErrorBuilder(mockAnalyzer, mockReplacer).buildSpanError(mockTracer, true, 400, "This web response message will be overridden", fakeThrowable);
assertSpanError(target, 400, IllegalArgumentException.class, "what did I do?", true);
}
use of com.newrelic.agent.model.SpanError in project newrelic-java-agent by newrelic.
the class SpanErrorBuilderTest method shouldBypassIgnoreReportableAndReplacementRulesForNoticedErrors.
@Test
public void shouldBypassIgnoreReportableAndReplacementRulesForNoticedErrors() {
when(mockAnalyzer.isReportable(anyInt(), ArgumentMatchers.<Throwable>any())).thenThrow(new AssertionError("should not have been called"));
when(mockAnalyzer.isReportable(anyInt())).thenReturn(false);
when(mockTracer.getException()).thenReturn(new RuntimeException("~~ unstripped due to api ~~"));
when(mockTracer.wasExceptionSetByAPI()).thenReturn(true);
when(mockReplacer.getMessage(ArgumentMatchers.<Throwable>any())).thenThrow(new AssertionError("should not have been called"));
SpanError target = new SpanErrorBuilder(mockAnalyzer, mockReplacer).buildSpanError(mockTracer, false, 400, "fine", null);
assertSpanError(target, null, RuntimeException.class, "~~ unstripped due to api ~~", false);
}
use of com.newrelic.agent.model.SpanError in project newrelic-java-agent by newrelic.
the class SpanErrorBuilderTest method shouldAddStatusAndExceptionToRootSpans.
@Test
public void shouldAddStatusAndExceptionToRootSpans() {
when(mockAnalyzer.isReportable(anyInt(), ArgumentMatchers.<Throwable>any())).thenReturn(true);
when(mockAnalyzer.isReportable(anyInt())).thenReturn(true);
when(mockTracer.getException()).thenReturn(new RuntimeException());
when(mockTracer.wasExceptionSetByAPI()).thenReturn(false);
when(mockReplacer.getMessage(ArgumentMatchers.<Throwable>any())).thenReturn("replaced message");
SpanError target = new SpanErrorBuilder(mockAnalyzer, mockReplacer).buildSpanError(mockTracer, true, 400, "fine", null);
assertSpanError(target, 400, RuntimeException.class, "replaced message", false);
}
Aggregations