Debugging information for JAVA agent

(Dark Shadow Side) #21

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();
        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 (
            System.out.println(rs.getString("uname") + rs.getString("esmeaddr"));
    catch (Exception e)
            throw e;
        catch (Exception e1)
        catch (InterruptedException e)


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": "", "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": "", "user-agent": "java-agent/1.1.0", "error": "read tcp> wsarecv: An existing connection was forcibly closed by the remote host."}

(Felix Barnsteiner) #22

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?

(Dark Shadow Side) #23


(Felix Barnsteiner) #24

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:

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

(Felix Barnsteiner) #25

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

I have created a PR to flush the events on application shutdown:

(Jan) #26

Yes it was succesfull,

On holiday right now,

Will pick it up after the first of Jan

(Jan) #27

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.


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

(system) closed #28

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