Add Spring Boot version to MongoDB driver handshake and append metadata for user-provided clients#50449
Draft
alexbevi wants to merge 2 commits into
Draft
Add Spring Boot version to MongoDB driver handshake and append metadata for user-provided clients#50449alexbevi wants to merge 2 commits into
alexbevi wants to merge 2 commits into
Conversation
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>
9f6fdb7 to
2cf279b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhance Spring Boot's MongoDB client metadata reporting:
Add
driverVersionto the existingMongoDriverInformationinMongoClientFactorySupport, so the handshake includes the Spring Boot version (not just the name) when Spring Boot constructs theMongoClient.Append metadata to user-provided clients: When a
MongoClientbean is created externally by the user, Spring Boot now callsappendMetadatavia reflection at the point it first uses the client — inMongoDatabaseFactoryConfiguration(blocking) andDataMongoReactiveAutoConfiguration(reactive). This ensures MongoDB server-side telemetry registers Spring Boot usage regardless of who constructs the client.Reflection is used for
appendMetadatabecause 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.