Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-3265

Pass Context value to the LogSink interface if available

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.1.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Go Drivers

      Context

      A common use for a Context is passing around request-scoped information so it can be added to log messages (e.g. request ID, user ID, etc). The current options.LogSink interface doesn't support passing the Context passed to an operation through to the logging implementation, meaning there's no simple way to access user-defined request-scoped data from the LogSink calls.

      For example, I want to pass a Context containing the current application user ID to an Insert MongoDB operation call. Then, in my LogSink adapter, I want to be able to access that Context and retrieve the user ID so I can add it to the logged message.

      Definition of done

      • Investigate ways to pass Context values to the LogSink calls without changing the LogSink API.
      • Investigate ways to modify the LogSink API to allow passing Context values.
        • For Go Driver v3.x, consider updating the LogSink API to work better with the new slog package, which supports passing Context values.

      Pitfalls

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: