Support delayed logging of Date_t via DynamicAttributes

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Networking & Observability
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Sometimes we want to fill out attributes for logging without inlining them into LOGV2 macro.

      Example: https://github.com/mongodb/mongo/blob/7b9c390b626f344bda268da9fcf048e0dc003921/src/mongo/db/op_debug.cpp#L198

      When we append a Date_t attribute, it is captured as CustomAttributeValue.

      However, when CustomAttributeValue is created, it captures the value to be logged via reference: 

      https://github.com/mongodb/mongo/blob/7b9c390b626f344bda268da9fcf048e0dc003921/src/mongo/logv2/attribute_storage.h#L335

      So if we want to log a Date_t object, we must ensure that the same instance of Date_t is alive between adding it to DynamicAttributes and actually logging those DynamicAttributes via LOGV2 macro.

       

      We should consider capturing small trivially-copyable objects by-value in CustomAttributeValue.

            Assignee:
            Unassigned
            Reporter:
            Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: