Search in sources :

Example 1 with Transaction

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

the class BodyProcessorTest method processTransaction.

private Transaction processTransaction() {
    final Transaction transaction = new Transaction();
    transaction.getContext().getRequest().withRawBody("foo");
    bodyProcessor.processBeforeReport(transaction);
    return transaction;
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction)

Example 2 with Transaction

use of co.elastic.apm.impl.transaction.Transaction 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)

Example 3 with Transaction

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

the class ElasticApmTracer method startTransaction.

@Nonnull
@Override
public Transaction startTransaction() {
    Transaction transaction;
    if (!coreConfiguration.isActive()) {
        transaction = noopTransaction;
    } else {
        transaction = transactionPool.createInstance().start(this, System.nanoTime(), sampler);
    }
    currentTransaction.set(transaction);
    return transaction;
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) Nonnull(javax.annotation.Nonnull)

Example 4 with Transaction

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

the class ElasticApmTracer method startSpan.

@Nonnull
@Override
public Span startSpan() {
    Transaction transaction = currentTransaction();
    final Span span;
    // even when setting active=false mid-transaction
    if (isNoop(transaction)) {
        span = noopSpan;
    } else {
        span = createRealSpan(transaction);
    }
    currentSpan.set(span);
    return span;
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) Span(co.elastic.apm.impl.transaction.Span) Nonnull(javax.annotation.Nonnull)

Example 5 with Transaction

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

the class BodyProcessorTest method processBeforeReport_Transaction_EventTypeAll.

@Test
void processBeforeReport_Transaction_EventTypeAll() {
    when(config.getCaptureBody()).thenReturn(WebConfiguration.EventType.ALL);
    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