Search in sources :

Example 11 with Transaction

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

the class BodyProcessorTest method processBeforeReport_Transaction_EventTypeError.

@Test
void processBeforeReport_Transaction_EventTypeError() {
    when(config.getCaptureBody()).thenReturn(WebConfiguration.EventType.ERRORS);
    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 12 with Transaction

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

the class ApmServerReporterIntegrationTest method testSecretToken.

@Test
void testSecretToken() throws ExecutionException, InterruptedException {
    when(reporterConfiguration.getSecretToken()).thenReturn("token");
    handler = exchange -> {
        assertThat(exchange.getRequestHeaders().get("Authorization").getFirst()).isEqualTo("Bearer token");
        receivedHttpRequests.incrementAndGet();
        exchange.setStatusCode(200).endExchange();
    };
    reporter.report(new Transaction());
    reporter.flush().get();
    assertThat(reporter.getDropped()).isEqualTo(0);
    assertThat(receivedHttpRequests.get()).isEqualTo(1);
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) Test(org.junit.jupiter.api.Test)

Example 13 with Transaction

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

the class ApmServerReporterIntegrationTest method testReportTransaction.

@Test
void testReportTransaction() throws ExecutionException, InterruptedException {
    reporter.report(new Transaction());
    reporter.flush().get();
    assertThat(reporter.getDropped()).isEqualTo(0);
    assertThat(receivedHttpRequests.get()).isEqualTo(1);
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) Test(org.junit.jupiter.api.Test)

Example 14 with Transaction

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

the class TransactionPayloadJsonSchemaTest method createTransactionWithRequiredValues.

private Transaction createTransactionWithRequiredValues() {
    Transaction t = new Transaction();
    t.start(mock(ElasticApmTracer.class), 0, ConstantSampler.of(true));
    t.setType("type");
    t.getContext().getRequest().withMethod("GET");
    Span s = new Span();
    s.start(mock(ElasticApmTracer.class), t, null, 0, false).withType("type").withName("name");
    t.addSpan(s);
    return t;
}
Also used : Transaction(co.elastic.apm.impl.transaction.Transaction) ElasticApmTracer(co.elastic.apm.impl.ElasticApmTracer) Span(co.elastic.apm.impl.transaction.Span)

Example 15 with Transaction

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

the class AbstractReporterBenchmark method setUp.

@Setup
public void setUp() throws Exception {
    tracer = ElasticApmTracer.builder().reporter(reporter).stacktraceFactory(StacktraceFactory.Noop.INSTANCE).build();
    // in contrast to production configuration, do not drop transactions if the ring buffer is full
    // instead blocking wait until a slot becomes available
    // this is important because otherwise we would not measure the speed at which events can be handled
    // but rather how fast events get discarded
    payloadSender = getPayloadSender();
    Service service = new Service().withName("java-test").withVersion("1.0").withEnvironment("test").withAgent(new Agent("elastic-apm-java", "1.0.0")).withRuntime(new RuntimeInfo("Java", "9.0.4")).withFramework(new Framework("Servlet API", "3.1")).withLanguage(new Language("Java", "9.0.4"));
    ProcessInfo process = new ProcessInfo("/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/java").withPid(2103).withPpid(403L).withArgv(Collections.singletonList("-javaagent:/path/to/elastic-apm-java.jar"));
    SystemInfo system = new SystemInfo("x86_64", "Felixs-MBP", "Mac OS X");
    ReporterConfiguration reporterConfiguration = new ReporterConfiguration();
    reporter = new ApmServerReporter(tracer.getConfigurationRegistry(), service, process, system, payloadSender, false, reporterConfiguration);
    payload = new TransactionPayload(process, service, system);
    for (int i = 0; i < reporterConfiguration.getMaxQueueSize(); i++) {
        Transaction t = new Transaction();
        t.start(tracer, 0, ConstantSampler.of(true));
        fillTransaction(t);
        payload.getTransactions().add(t);
    }
}
Also used : Agent(co.elastic.apm.impl.payload.Agent) SystemInfo(co.elastic.apm.impl.payload.SystemInfo) RuntimeInfo(co.elastic.apm.impl.payload.RuntimeInfo) Language(co.elastic.apm.impl.payload.Language) Transaction(co.elastic.apm.impl.transaction.Transaction) ApmServerReporter(co.elastic.apm.report.ApmServerReporter) Service(co.elastic.apm.impl.payload.Service) ProcessInfo(co.elastic.apm.impl.payload.ProcessInfo) TransactionPayload(co.elastic.apm.impl.payload.TransactionPayload) ReporterConfiguration(co.elastic.apm.report.ReporterConfiguration) Framework(co.elastic.apm.impl.payload.Framework) Setup(org.openjdk.jmh.annotations.Setup)

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