[JAVA-5260] Add support for "comment suppliers" Created: 04/Dec/23  Updated: 04/Jan/24

Status: Investigating
Project: Java Driver
Component/s: Query Operations
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Unknown
Reporter: Nat Mishkin Assignee: Ashni Mehta
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

My application is a web server that uses "request IDs" that are generated by nginx on all incoming HTTP requests and then carried through all of my server's logic and across threads and in any remote requests it itself makes. Request IDs appear as part of all log messages. Request IDs are stored in thread-local storage (not passed parametrically). I want these request IDs to be passed to MongoDB as "comments" so I can associate any DB issues that MongoDB logs to also contain my request IDs. This will let me figure out what incoming request to my application (and other associated activity) led to the DB issue.

Changing my code to pass a comment in each place where it does a DB operation is not practical. Instead I'm imagining an extension to the Java Driver API that allows an application to register what I'll call a "comment supplier", an implementation of some new interface that gets called by the Driver to get a comment on the fly before the Driver sends a request to the Mongo server.



 Comments   
Comment by Nat Mishkin [ 04/Jan/24 ]

The comments would be used primarily for debugging performance problems. E.g., starting with a "slow query" log line produced by mongod I could used the logged comment–which would be a request ID–to trace the problem back to the original HTTP request that my server received because my server logs the request ID with each incoming request. The same request ID also appears in all other log messages produced by my server. So with one query for a request ID across all my logs, I can get a full picture of the events that led to the "slow query" log line.

Comment by Ashni Mehta [ 04/Jan/24 ]

Hi nmishkin@onshape.com , thank you for filing this feature request. It's definitely an interesting idea. To make sure I understand your specific use case, what will these comments be used for? Are they for debugging, as part of traces, or something else?

Comment by PM Bot [ 04/Dec/23 ]

Hi nmishkin@onshape.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Thu Feb 08 09:04:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.