[SERVER-47594] Create LOG(v2) helpers for collection-type objects Created: 16/Apr/20  Updated: 29/Oct/23  Resolved: 05/May/20

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.4.0-rc7, 4.7.0

Type: Improvement Priority: Major - P3
Reporter: Daniel Gottlieb (Inactive) Assignee: Henrik Edin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-57680 Use namespace instead of nss for nami... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.4
Sprint: Execution Team 2020-05-04, Execution Team 2020-05-18
Participants:

 Description   

There's a request to standardize that a collection's <database.collection> string representation are logged with the attribute key "namespace". Additionally, it's often useful to have the associated UUID. While it's unlikely we can completely codify that a mistake never happens, the following helpers would go a long way by making it easier to log the right thing than the wrong thing:
Instead of being forced to type, e.g:

LOGV2(0, "Dropping collection", "namespace"_attr = collection->ns(), "uuid"_attr = collection->uuid());

The following example API (not the mandated solution) would be easier and safer:

LOGV2(0, "Dropping collection", Attr(collection));

Additionally, some methods don't have collection objects, but `Namespace` objects. Having those transformed (without the UUID component) would also be beneficial.

Note there are some more complicated, but uncommon scenarios that may not be worth covering. Such as log lines for renaming collections that can include source/target and temporary collections. The suggested guidance for those cases is to log sourceNamespace and targetNamespace. Having that possible would be a win, but not a requirement.



 Comments   
Comment by Githook User [ 18/May/20 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-47594 Add helpers to Structured Logging to abstract attribute names

  • Users can implement logAttrs() for their types to provide common attribute names
  • multipleAttrs can be used to provide multiple attributes for an object

(cherry picked from commit c65076829b29f977d6412f5309a3b8cf56ce9657)
Branch: v4.4
https://github.com/mongodb/mongo/commit/d868c9b4c537f29b1b92b1d5fb11bf5c8eed5ef3

Comment by Henrik Edin [ 15/May/20 ]

Requesting backport so code that uses 'logAttrs' can be backported to v4.4.

Comment by Githook User [ 05/May/20 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-47594 Add helpers to Structured Logging to abstract attribute names

Generated at Thu Feb 08 05:14:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.