Debugging information for JAVA agent

Hi felixbarny,
below is my code but still I can't see the stats.
public class TestAPM
{

public static void main(String[] args)
{
    String TransactionID = args[0];
    String SpanID = args[1];
    Transaction transaction = ElasticApm.startTransaction();
    try
    {
        transaction.setName("TransactionID");
        transaction.setType(Transaction.TYPE_REQUEST);
        
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/billing", "devuser", "devuser");
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("Select uname,esmeaddr from custdb.Users LIMIT 5");
        while (rs.next())
        {
            System.out.println(rs.getString("uname") + rs.getString("esmeaddr"));
            TimeUnit.SECONDS.sleep(5);
        }
    }
    catch (Exception e)
    {
        transaction.captureException(e);
        try
        {
            throw e;
        }
        catch (Exception e1)
        {
            e1.printStackTrace();
        }
    }
    finally
    {
        try
        {
            TimeUnit.SECONDS.sleep(10);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
        transaction.end();
    }
}

}

LOG:
2018-12-19T13:07:34.896+0530 INFO [request] beater/common_handlers.go:272 handled request {"request_id": "ac290c88-f3ca-459c-b3d6-a3ddd198ec85", "method": "GET", "URL": "/", "content_length": 0, "remote_address": "127.0.0.1", "user-agent": "Java/1.8.0_171", "response_code": 200}
2018-12-19T13:08:11.295+0530 INFO [request] beater/v2_handler.go:111 error handling request {"request_id": "3428ca85-9528-4862-b6f2-f0d299596292", "method": "POST", "URL": "/intake/v2/events", "content_length": -1, "remote_address": "127.0.0.1", "user-agent": "java-agent/1.1.0", "error": "read tcp 127.0.0.1:8200->127.0.0.1:54510: wsarecv: An existing connection was forcibly closed by the remote host."}

That's interesting. There seems to be a problem with the connection from the agent to the server. Are there any proxies or firewalls in between you may need to adjust? Could you post the logs from the agent?

Sure,
https://pastebin.com/63MDQGcd

Ah, I think I know what the problem is. Your program terminates before the agent sends the data from the background thread to the server!

What you can do is to wait 20 seconds before terminating the program. You can also adjust the flush interval with this setting: https://www.elastic.co/guide/en/apm/agent/java/current/config-reporter.html#config-flush-interval.

I'll submit a patch so that it flushes the data on exit.

Have you had success when waiting for the events to be sent?

I have created a PR to flush the events on application shutdown: https://github.com/elastic/apm-agent-java/pull/397

Yes it was succesfull,

On holiday right now,

Will pick it up after the first of Jan

Have managed to get things running on localhost, getting quite some information back. The configuration of the
run-VM arguments of eclipse
resolved it.
A bit confusing as it is also referenced inside my pom.xml file.

-javaagent:H:\elastic-apm-agent-1.1.0.jar
-Delastic.apm.service_name=TestAPM
-Delastic.apm.server_url=http://localhost:8200
-Delastic.apm.application_packages=org.xx
-Delastic.apm.log_level=INFO

Some other issues on the horizon now,
different topic though.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.