question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tracing JDBC connection creation

See original GitHub issue

JDBC 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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:23 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
matthiaswelzcommented, Nov 5, 2021

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, the getConnection 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.

2reactions
eyalkorencommented, Nov 25, 2019

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-active java.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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found