minitrace-rust icon indicating copy to clipboard operation
minitrace-rust copied to clipboard

Feature: Valuable support or record!(span,"key", "value")

Open taqtiqa-mark opened this issue 2 years ago • 1 comments

We should document whether or not we support the valuable crate. The tracing crate has announced experimental support

Use case: This allows users to record both user-defined types, and standard library collections such as Vec and HashMap, as structured data attached to tracing spans.

Case For

  1. We mimic the tracing crate - its familiar for tracing users.
  2. It is convenient.

Case Against

  1. It's a special-purpose use case, e.g. debugging, we can likely better support more simply.
  2. We should discourage pushing complex user-defined types, and standard library collections to the tracing UI as a general practice - moving such volumes of data around the network will cripple your app performance - see 1.
  3. As we mimic tracing crate behavior we can expect to approach tracing "like" performance.
  4. It's yet another crate to build.

One Alternative

Better, in my mind, is to stick with a simple record!(span, "key", "value") API.
For more complex use cases, the documents should encourage users to employ the standard format!(). Specifically, for example: record!(span, "key", format!("{:#?}", udt)). For more complex user defined types and data they have the ability to implement Display and/or Debug traits. The Debug trait will likely already exist in most development stories. In performance monitoring stories there are strong incentives to keep-it-simple, and here the Display trait can be repurposed to support that use case.

We should document whether or not "Object-safe value inspection, used to pass un-typed structured data across trait-object boundaries." is within the scope of Minitrace, or not. I think not.

Thoughts?

In particular, my focus (head-space), is occupied by the #[trace] attribute... there may be Minitrace implementation details that mean it is more performant to use the valuable crate when recording and passing these data to Jaeger, datadog etc.

taqtiqa-mark avatar Apr 12 '22 21:04 taqtiqa-mark

Better, in my mind, is to stick with a simple span.record("key", "value") API.

In fact we could make the public API even smaller with record!(span,"key", "value")

taqtiqa-mark avatar Apr 13 '22 20:04 taqtiqa-mark

since minitrace is compatible with the log crate, the structured log can be attached to span via logging macro from log crate.

andylokandy avatar Jul 18 '23 15:07 andylokandy