use of co.elastic.apm.impl.error.ErrorCapture in project apm-agent-java by elastic.
the class ApmServerReporterIntegrationTest method testReportErrorCapture.
@Test
void testReportErrorCapture() throws ExecutionException, InterruptedException {
reporter.report(new ErrorCapture());
reporter.flush().get();
assertThat(reporter.getDropped()).isEqualTo(0);
assertThat(receivedHttpRequests.get()).isEqualTo(1);
}
use of co.elastic.apm.impl.error.ErrorCapture in project apm-agent-java by elastic.
the class BodyProcessorTest method processBeforeReport_Error_EventTypeAll.
@Test
void processBeforeReport_Error_EventTypeAll() {
when(config.getCaptureBody()).thenReturn(WebConfiguration.EventType.ALL);
final ErrorCapture error = processError();
assertThat(error.getContext().getRequest().getBody()).isEqualTo("foo");
}
use of co.elastic.apm.impl.error.ErrorCapture in project apm-agent-java by elastic.
the class BodyProcessorTest method processBeforeReport_Error_EventTypeTransaction.
@Test
void processBeforeReport_Error_EventTypeTransaction() {
when(config.getCaptureBody()).thenReturn(WebConfiguration.EventType.TRANSACTIONS);
final ErrorCapture error = processError();
assertThat(error.getContext().getRequest().getBody()).isEqualTo("[REDACTED]");
}
use of co.elastic.apm.impl.error.ErrorCapture in project apm-agent-java by elastic.
the class BodyProcessorTest method processBeforeReport_Error_EventTypeError.
@Test
void processBeforeReport_Error_EventTypeError() {
when(config.getCaptureBody()).thenReturn(WebConfiguration.EventType.ERRORS);
final ErrorCapture error = processError();
assertThat(error.getContext().getRequest().getBody()).isEqualTo("foo");
}
use of co.elastic.apm.impl.error.ErrorCapture in project apm-agent-java by elastic.
the class ElasticApmTracer method captureException.
public void captureException(Exception e) {
ErrorCapture error = new ErrorCapture();
error.getId().setToRandomValue();
error.withTimestamp(System.currentTimeMillis());
error.getException().withMessage(e.getMessage());
error.getException().withType(e.getClass().getName());
stacktraceFactory.fillStackTrace(error.getException().getStacktrace(), e.getStackTrace());
Transaction transaction = currentTransaction();
if (transaction != null) {
error.getTransaction().withId(transaction.getId());
error.getContext().copyFrom(transaction.getContext());
}
reporter.report(error);
}
Aggregations