Skip to content

feat: add MongoDB client metadata#614

Merged
mkjsix merged 1 commit into
SoftInstigate:masterfrom
alexbevi:add-client-metadata
May 1, 2026
Merged

feat: add MongoDB client metadata#614
mkjsix merged 1 commit into
SoftInstigate:masterfrom
alexbevi:add-client-metadata

Conversation

@alexbevi
Copy link
Copy Markdown
Contributor

@alexbevi alexbevi commented Apr 21, 2026

The PR incorporates MongoDB's wrapping client library specification for the connection handshake to allow library details to be included in the metadata written to mongos or mongod logs.

For example, this change would allow server-side logs such as the following:

{"t":{"$date":"2026-04-20T11:33:05.688+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn70990","msg":"client metadata","attr":{"remote":"192.168.0.1:34567","client":"conn70990","negotiatedCompressors":["zstd"],"doc":{"application":{"name":"my-api-app"},"driver":{"name":"mongo-java-driver|RESTHeart","version":"5.0.0|9.0.0"},"os":{"type":"Linux","name":"Linux","architecture":"amd64","version":"6.1.119-129.201.amzn2023.x86_64"},"platform":"Java/Amazon.com Inc./21.0.8+9-LTS"}}}

For anyone hosting clusters with connections coming from different applications this can help differentiate connections and facilitate log analysis.

This is effectively the same approach taken by Spring Data MongoDB (see SpringDataMongoDB.java, AbstractMongoClientConfiguration.java), and just added to Morphia.

Pass MongoDriverInformation to MongoClients.create() so RESTHeart
is identified in the MongoDB driver handshake for server-side telemetry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@mkjsix
Copy link
Copy Markdown
Member

mkjsix commented May 1, 2026

This is particularly valuable in multi-application environments where multiple services connect to the same MongoDB cluster:

Microservices architectures — Identify which service made which query
Multi-tenant deployments — Differentiate connections by application
Troubleshooting — Ops teams can quickly identify and isolate RESTHeart-related connection issues
Log analysis — Correlate MongoDB server logs with application logs more easily
Part of a Broader Ecosystem
This approach is now becoming standard across MongoDB drivers and libraries:

✅ Spring Data MongoDB — Already implements this
✅ Morphia — Recently added support
✅ RESTHeart — This PR completes the adoption

Any application using the MongoDB Java driver can implement this pattern, creating a unified view of connections in MongoDB server logs.

@mkjsix mkjsix self-requested a review May 1, 2026 09:52
@mkjsix mkjsix self-assigned this May 1, 2026
@mkjsix mkjsix added this to the 9.3.0 milestone May 1, 2026
@mkjsix mkjsix merged commit 6a67394 into SoftInstigate:master May 1, 2026
7 checks passed
mkjsix pushed a commit that referenced this pull request May 1, 2026
Pass MongoDriverInformation to MongoClients.create() so RESTHeart
is identified in the MongoDB driver handshake for server-side telemetry.
@mkjsix
Copy link
Copy Markdown
Member

mkjsix commented May 7, 2026

This is included in release 9.3.0
https://github.com/SoftInstigate/restheart/releases/tag/9.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants