Skip to content

v1.1 Release Notes

Tadaya Tsuyukubo edited this page Feb 23, 2025 · 2 revisions

Datasource Micrometer v1.1 Release Notes

New Features

Spring Event Publishing

When jdbc.event.enabled property is set to true, JdbcEventPublishingListener is registered and publishes JdbcQueryExecutionEvent and JdbcQueryExecutionEvent as Spring application events.

Recorded ResultSet Interactions

The ResultSetContext observation context now holds a list of ResultSetOperation instances, representing interactions with a ResultSet.

For example, the following JDBC query results in recorded operations:

String query = "select id, job, name from emp where name != ?";
try (PreparedStatement ps = connection.prepareStatement(query)) {
    ps.setString(1, "Foo");
    try (ResultSet rs = ps.executeQuery()) {
        while (rs.next()) {
            Integer id = rs.getInt("id");
            String job = rs.getString("job");
            // Process result
        }
    }
}

Recorded ResultSetOperation:

Method Arguments Value
next null true
getInt ["id"] 1
getString ["job"] "engineer"
next null true
getInt ["id"] 2
getString ["job"] "teacher"
next null false
close null null

This allows for generating an easy visualization of query results like this:

id job
1 engineer
2 teacher

Generated Keys Observation

A new observation has been introduced for tracking generated keys.

When inserting records with auto-generated keys, Statement#getGeneratedKeys() returns a ResultSet. The interactions with this ResultSet create a new observation, tagging retrieved keys.

Example Usage:

PreparedStatement stmt = conn.prepareStatement(
    "INSERT INTO emp (name) VALUES (?)", 
    Statement.RETURN_GENERATED_KEYS
);
stmt.setString(1, "FOO");
stmt.executeUpdate();

try (ResultSet rs = stmt.getGeneratedKeys()) {
    rs.next();
    Integer id = rs.getInt(1);
}

If the insert generates id=100, the observation will include the tag: jdbc.generated-keys=100.


Changes

Default DataSource Becomes a Pure JDK Proxy

Previously, the instrumented DataSource was a ProxyDataSource instance.
From this version onward, it returns a pure JDK proxy object.
This behavior can be controlled via the property: jdbc.datasource-proxy.type.

Datasource Name as a Low Cardinality Key

The datasource name is now available as a low-cardinality key under jdbc.datasource.name.


Compatibilities

  • Tested with Spring Boot 3.4 and 3.5 (M2); should work with prior versions.
  • Micrometer: No known compatibility issues with previous versions.