Search in sources :

Example 1 with ErrorCapture

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);
}
Also used : ErrorCapture(co.elastic.apm.impl.error.ErrorCapture) Test(org.junit.jupiter.api.Test)

Example 2 with ErrorCapture

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");
}
Also used : ErrorCapture(co.elastic.apm.impl.error.ErrorCapture) Test(org.junit.jupiter.api.Test)

Example 3 with ErrorCapture

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]");
}
Also used : ErrorCapture(co.elastic.apm.impl.error.ErrorCapture) Test(org.junit.jupiter.api.Test)

Example 4 with ErrorCapture

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");
}
Also used : ErrorCapture(co.elastic.apm.impl.error.ErrorCapture) Test(org.junit.jupiter.api.Test)

Example 5 with ErrorCapture

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);
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) ErrorCapture(co.elastic.apm.impl.error.ErrorCapture)

Aggregations

ErrorCapture (co.elastic.apm.impl.error.ErrorCapture)7 Test (org.junit.jupiter.api.Test)5 Transaction (co.elastic.apm.impl.transaction.Transaction)1