Tracing JDBC connection creation
See original GitHub issueJDBC open connection and resultSet.next() is not logging in span
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup(dsName);
conn=ds.getConnection();
stmt=conn.createStatement();
rset=stmt.executeQuery("select a.* from editor.cw_news a");
while (rset.next()){
out.print("<br>"+ rset.getString("newstitle"));
}
Transaction show just the select span and there is no logging for open connection time and resultSet retrieve time
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:23 (18 by maintainers)
Top Results From Across the Web
Trace a JDBC Connection Using a Connection String
Start tracing by adding an option in the connection string when creating a JDBC connection.
Read more >Tracing driver operation (logging) - JDBC Driver for SQL Server
The Microsoft JDBC Driver for SQL Server supports the use of tracing (or logging) to help resolve issues and problems with the JDBC...
Read more >How to enable JDBC tracing for DataSource based connections
Use DataDirect Spy to generate a JDBC trace file when using DataSource based connections. To make DataDirect Spy available, ...
Read more >Tracing with the IBM Data Server Driver for JDBC and SQLJ
If a trace directory is defined, a separate trace file is created for each database connection.
Read more >Diagnosability in JDBC - Oracle Help Center
Set the UMASK for the directory where the trace file is created. This will restrict user access to the trace file. Not enable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have just created a really simple plugin to instrument
DataSource#getConnection
like @CoderLan0668 and attached it to one of my real-world applications. After running a very simple performance test, I can see that in some traces, thegetConnection
calls account for over 50% of the transaction time.Of course, my example might not be representative about the elastic community. But I definitely wanted to voice my support for this feature - I definitely see value in this instrumentation and would welcome to see something in the elastic-apm-agent in the future out-of-the box.
Without looking too much into this, it seems that
java.sql.Driver#connect
would be a native candidate for that.NOTE: by instrumenting
java.sql.Driver#connect
we may eliminate the possibly-activejava.sql.Connection#getMetaData
usage, getting the URL from the first argument, the user from the second (java.util.Properties
) argument and the vendor based on the Driver class name.