Search in sources :

Example 1 with ProcessInfo

use of co.elastic.apm.impl.payload.ProcessInfo in project apm-agent-java by elastic.

the class ApmServerReporterIntegrationTest method setUp.

@BeforeEach
void setUp() {
    handler = exchange -> {
        receivedHttpRequests.incrementAndGet();
        exchange.setStatusCode(200).endExchange();
    };
    receivedHttpRequests.set(0);
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new AfterburnerModule());
    final ConfigurationRegistry config = SpyConfiguration.createSpyConfig();
    reporterConfiguration = config.getConfig(ReporterConfiguration.class);
    when(reporterConfiguration.getFlushInterval()).thenReturn(-1);
    when(reporterConfiguration.getServerUrl()).thenReturn("http://localhost:" + port);
    payloadSender = new ApmServerHttpPayloadSender(new OkHttpClient(), new JacksonPayloadSerializer(objectMapper), reporterConfiguration);
    SystemInfo system = new SystemInfo("x64", "localhost", "platform");
    reporter = new ApmServerReporter(config, new Service(), new ProcessInfo("title"), system, payloadSender, false, reporterConfiguration);
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) OkHttpClient(okhttp3.OkHttpClient) SystemInfo(co.elastic.apm.impl.payload.SystemInfo) JacksonPayloadSerializer(co.elastic.apm.report.serialize.JacksonPayloadSerializer) ConfigurationRegistry(org.stagemonitor.configuration.ConfigurationRegistry) Service(co.elastic.apm.impl.payload.Service) ProcessInfo(co.elastic.apm.impl.payload.ProcessInfo) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ProcessInfo

use of co.elastic.apm.impl.payload.ProcessInfo in project apm-agent-java by elastic.

the class ApmServerReporterTest method setUp.

@BeforeEach
void setUp() {
    final ConfigurationRegistry configurationRegistry = SpyConfiguration.createSpyConfig();
    ReporterConfiguration reporterConfiguration = configurationRegistry.getConfig(ReporterConfiguration.class);
    when(reporterConfiguration.getFlushInterval()).thenReturn(-1);
    when(reporterConfiguration.getMaxQueueSize()).thenReturn(0);
    SystemInfo system = new SystemInfo("x64", "localhost", "platform");
    reporter = new ApmServerReporter(configurationRegistry, new Service(), new ProcessInfo("title"), system, mock(PayloadSender.class), true, reporterConfiguration);
}
Also used : SystemInfo(co.elastic.apm.impl.payload.SystemInfo) ConfigurationRegistry(org.stagemonitor.configuration.ConfigurationRegistry) Service(co.elastic.apm.impl.payload.Service) ProcessInfo(co.elastic.apm.impl.payload.ProcessInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ProcessInfo

use of co.elastic.apm.impl.payload.ProcessInfo in project apm-agent-java by elastic.

the class ProcessFactoryTest method testProcessInformationForCurrentVm.

@Test
void testProcessInformationForCurrentVm() {
    ProcessInfo proc = ProcessFactory.ForCurrentVM.INSTANCE.getProcessInformation();
    assertSoftly(softly -> {
        softly.assertThat(proc.getArgv()).isNotEmpty();
        softly.assertThat(proc.getPid()).isNotEqualTo(0);
        softly.assertThat(proc.getPpid()).isNotNull();
        softly.assertThat(proc.getTitle()).contains("java");
    });
}
Also used : ProcessInfo(co.elastic.apm.impl.payload.ProcessInfo) Test(org.junit.jupiter.api.Test)

Example 4 with ProcessInfo

use of co.elastic.apm.impl.payload.ProcessInfo in project apm-agent-java by elastic.

the class ProcessFactoryTest method testProcessInformationForLegacyVm.

@Test
void testProcessInformationForLegacyVm() {
    ProcessInfo proc = ProcessFactory.ForLegacyVM.INSTANCE.getProcessInformation();
    assertSoftly(softly -> {
        softly.assertThat(proc.getArgv()).isNotEmpty();
        softly.assertThat(proc.getPid()).isNotEqualTo(0);
        softly.assertThat(proc.getTitle()).contains("java");
    });
}
Also used : ProcessInfo(co.elastic.apm.impl.payload.ProcessInfo) Test(org.junit.jupiter.api.Test)

Example 5 with ProcessInfo

use of co.elastic.apm.impl.payload.ProcessInfo 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

ProcessInfo (co.elastic.apm.impl.payload.ProcessInfo)5 Service (co.elastic.apm.impl.payload.Service)3 SystemInfo (co.elastic.apm.impl.payload.SystemInfo)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 ConfigurationRegistry (org.stagemonitor.configuration.ConfigurationRegistry)2 Agent (co.elastic.apm.impl.payload.Agent)1 Framework (co.elastic.apm.impl.payload.Framework)1 Language (co.elastic.apm.impl.payload.Language)1 RuntimeInfo (co.elastic.apm.impl.payload.RuntimeInfo)1 TransactionPayload (co.elastic.apm.impl.payload.TransactionPayload)1 Transaction (co.elastic.apm.impl.transaction.Transaction)1 ApmServerReporter (co.elastic.apm.report.ApmServerReporter)1 ReporterConfiguration (co.elastic.apm.report.ReporterConfiguration)1 JacksonPayloadSerializer (co.elastic.apm.report.serialize.JacksonPayloadSerializer)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)1 OkHttpClient (okhttp3.OkHttpClient)1 Setup (org.openjdk.jmh.annotations.Setup)1