Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-1390

Record tracing spans in the driver

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      We are using the tracing crate to emit tracing/log events, which allows us to define "spans" that events happen in. This can make it easier for users to correlate events that are linked, e.g. all the events that happen within a single insert_one call.

      Users can instrument driver API calls themselves like:

      let res = coll
          .insert_one(doc! {"x" : 1 }, None)
          .instrument(debug_span!("insert_one_span"))
          .await; 

      Which will put all of the events the emitted as part of the call to insert_one within insert_one_span. Spans can also be nested, so any span created by e.g. tokio within there could be nested in that span.

      However, we could also define our own spans for intervals of interest within the driver, for example the execution of a single command. This could allow a user instrumenting an API call to easily identify if the call above involved a retry, since there would be two "command" spans within the insert_one span.

      While coming up with our plan for spans and introducing and testing them is not necessarily in scope for the logging spec implementation this would be nice add-on work to do once we have all of our events in place.

            Assignee:
            Unassigned Unassigned
            Reporter:
            kaitlin.mahar@mongodb.com Kaitlin Mahar
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: