SQL Spans with DB2 (JDBC 4)

APM Agent language and version:
Java / 1.11.0

Is there anything special in your setup? For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

DB2 (z/os)

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

Only the first query gets traced. No warnings are generated.

Steps to reproduce:

  1. Create a minimal Spring boot 2 application
  2. Add Ibm JDBC v4 drivers as dependency
  3. Create a DB2 (z/os) Datasource
  4. Create a scheduled bean, that invokes a simple query (e.g. select 1 from sysibm.sysdummy1) using prepared statement
  5. Start application with java-agent attached

Are there known issues with jdbc tracing?

Source code for reproducing:

@RequestMapping("/hello")
@RestController
public class TestController {
	private DataSource ds;

	public TestController() {
		DB2SimpleDataSource ds = new DB2SimpleDataSource();
		ds.setServerName("db2.com");
		ds.setPortNumber(5100);
		ds.setDatabaseName("DB2DB");
		ds.setUser("DB2USER");
		ds.setPassword("DB2PASS");
		ds.setFetchSize(10);
		ds.setDriverType(4);

		this.ds = ds;
	}

	@GetMapping
	public String hello() throws Exception {
		try (Connection c = ds.getConnection();
				PreparedStatement ps = c.prepareStatement("select 1 from sysibm.sysdummy1", ResultSet.TYPE_FORWARD_ONLY,
						ResultSet.CONCUR_READ_ONLY);
				ResultSet rs = ps.executeQuery()) {
			rs.next();
		}
		return "hello";
	}

	@Scheduled(fixedDelay = 1000)
	public void scheduled() throws Exception {
		hello();
	}
}

Hi Sami and welcome to the forum :slight_smile:

Looks like you figured it out - https://github.com/elastic/apm-agent-java/issues/925. We will provide you with a fix applying your suggestion and see if that works.

FYI, fix has been released in version 1.12.0 of Java agent.

Thanks a lot @skorhone for reporting and helping us fix this issue.

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