spring-projects / spring-projects/spring-data-mongodb

Add support for "comment suppliers"

Open
#4,581 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Although Spring Data MongoDB has support for MongoDB comments (e.g., Query.comment(String) and @Meta(comment = "...")) I'd like to see that support extended to support a use case I'd like to implement:

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 (and other associated activity) led to the DB issue.

Spring Data MongoDB's support for comments isn't general enough to support the above. One idea I have is to extend MongoTemplate to have some sort of setCommentSupplier(Supplier<String>) method. The supplied supplier would be called whenever Spring Data MongoDB is about to send a request to MongoDB. I'm sure there are other (and maybe better) ways to extend Spring Data MongoDB to support my use case too.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with MongoTemplate and the existing comment entry points Query.comment(String) and @Meta(comment = "..."). Compare those APIs with the request for a per-operation Supplier and determine how comments are attached before requests reach MongoDB. Done means a supported design lets request-scoped values become MongoDB comments for each outgoing request.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb
Domain
backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.