Search in sources :

Example 6 with Transaction

use of co.elastic.apm.impl.transaction.Transaction in project apm-agent-java by elastic.

the class ObjectPoolBenchmark method testMixedObjectPool.

// @Benchmark
@Threads(8)
public Transaction testMixedObjectPool() {
    Transaction transaction = mixedObjectPool.createInstance();
    mixedObjectPool.recycle(transaction);
    return transaction;
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) Threads(org.openjdk.jmh.annotations.Threads)

Example 7 with Transaction

use of co.elastic.apm.impl.transaction.Transaction in project apm-agent-java by elastic.

the class ObjectPoolBenchmark method testThreadLocalObjectPool.

@Benchmark
@Threads(8)
public Transaction testThreadLocalObjectPool() {
    Transaction transaction = threadLocalObjectPool.createInstance();
    threadLocalObjectPool.recycle(transaction);
    return transaction;
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) Threads(org.openjdk.jmh.annotations.Threads) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 8 with Transaction

use of co.elastic.apm.impl.transaction.Transaction in project apm-agent-java by elastic.

the class ApmFilter method captureTransaction.

void captureTransaction(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
    if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        final Transaction transaction = tracer.startTransaction();
        try {
            filterChain.doFilter(request, response);
            fillTransaction(transaction, httpRequest, (HttpServletResponse) response);
        } catch (IOException | RuntimeException | ServletException e) {
            tracer.captureException(e);
            throw e;
        } finally {
            transaction.end();
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletException(javax.servlet.ServletException) Transaction(co.elastic.apm.impl.transaction.Transaction) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException)

Example 9 with Transaction

use of co.elastic.apm.impl.transaction.Transaction in project apm-agent-java by elastic.

the class BodyProcessorTest method processBeforeReport_Transaction_EventTypeOff.

@Test
void processBeforeReport_Transaction_EventTypeOff() {
    when(config.getCaptureBody()).thenReturn(WebConfiguration.EventType.OFF);
    final Transaction transaction = processTransaction();
    assertThat(transaction.getContext().getRequest().getBody()).isEqualTo("[REDACTED]");
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) Test(org.junit.jupiter.api.Test)

Example 10 with Transaction

use of co.elastic.apm.impl.transaction.Transaction in project apm-agent-java by elastic.

the class BodyProcessorTest method processBeforeReport_Transaction_EventTypeTransaction.

@Test
void processBeforeReport_Transaction_EventTypeTransaction() {
    when(config.getCaptureBody()).thenReturn(WebConfiguration.EventType.TRANSACTIONS);
    final Transaction transaction = processTransaction();
    assertThat(transaction.getContext().getRequest().getBody()).isEqualTo("foo");
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) Test(org.junit.jupiter.api.Test)

Aggregations

Transaction (co.elastic.apm.impl.transaction.Transaction)17 Test (org.junit.jupiter.api.Test)6 Threads (org.openjdk.jmh.annotations.Threads)4 Span (co.elastic.apm.impl.transaction.Span)2 Nonnull (javax.annotation.Nonnull)2 Benchmark (org.openjdk.jmh.annotations.Benchmark)2 ElasticApmTracer (co.elastic.apm.impl.ElasticApmTracer)1 ErrorCapture (co.elastic.apm.impl.error.ErrorCapture)1 Agent (co.elastic.apm.impl.payload.Agent)1 Framework (co.elastic.apm.impl.payload.Framework)1 Language (co.elastic.apm.impl.payload.Language)1 ProcessInfo (co.elastic.apm.impl.payload.ProcessInfo)1 RuntimeInfo (co.elastic.apm.impl.payload.RuntimeInfo)1 Service (co.elastic.apm.impl.payload.Service)1 SystemInfo (co.elastic.apm.impl.payload.SystemInfo)1 TransactionPayload (co.elastic.apm.impl.payload.TransactionPayload)1 ApmServerReporter (co.elastic.apm.report.ApmServerReporter)1 ReporterConfiguration (co.elastic.apm.report.ReporterConfiguration)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1