Skip to content

Add Spring Boot version to MongoDB driver handshake and append metadata for user-provided clients#50449

Draft
alexbevi wants to merge 2 commits into
spring-projects:mainfrom
alexbevi:add-client-metadata
Draft

Add Spring Boot version to MongoDB driver handshake and append metadata for user-provided clients#50449
alexbevi wants to merge 2 commits into
spring-projects:mainfrom
alexbevi:add-client-metadata

Conversation

@alexbevi
Copy link
Copy Markdown

Enhance Spring Boot's MongoDB client metadata reporting:

  • Add driverVersion to the existing MongoDriverInformation in MongoClientFactorySupport, so the handshake includes the Spring Boot version (not just the name) when Spring Boot constructs the MongoClient.

  • Append metadata to user-provided clients: When a MongoClient bean is created externally by the user, Spring Boot now calls appendMetadata via reflection at the point it first uses the client — in MongoDatabaseFactoryConfiguration (blocking) and DataMongoReactiveAutoConfiguration (reactive). This ensures MongoDB server-side telemetry registers Spring Boot usage regardless of who constructs the client.

Reflection is used for appendMetadata because it was added in Java driver 5.6.0 and the actual driver version is governed by the Spring Data BOM — older versions skip the call silently.

alexbevi and others added 2 commits May 15, 2026 13:34
The MongoDriverInformation already includes driverName("spring-boot") but
was missing the version. This adds driverVersion so MongoDB server-side
telemetry can distinguish traffic by Spring Boot release.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Alex Bevilacqua <alex@alexbevi.com>
When a MongoClient is created externally by the user (Pattern B), Spring
Boot now calls appendMetadata via reflection to register "spring-boot"
driver info. This covers both blocking (MongoDatabaseFactoryConfiguration)
and reactive (DataMongoReactiveAutoConfiguration) paths. Reflection is
used because appendMetadata was added in Java driver 5.6.0 and the actual
version is managed by the Spring Data BOM.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Alex Bevilacqua <alex@alexbevi.com>
@alexbevi alexbevi force-pushed the add-client-metadata branch from 9f6fdb7 to 2cf279b Compare May 15, 2026 17:35
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 15, 2026
@alexbevi alexbevi marked this pull request as draft May 15, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants