davidbarsky / tracing-tree

Apache License 2.0
123 stars 31 forks source link

Needs finer time precision #67

Closed hrmsk66 closed 11 months ago

hrmsk66 commented 1 year ago

The current time precision does not account for durations less than 1ms, rendering them as 0ms. Also, the absence of decimal points in the time unit output often results in events that are hard to distinguish on the timeline when the unit becomes seconds.

For example, the current output looks like this:

┐run{hostname="localhost"}
├─  0ms TRACE Request received
├─┐fetch_httpbin{method=GET, path="/"}
│ ├─  4s  DEBUG Response received, backend=httpbin, status=200 OK, cache_status=MISS
├─┘
├─┐fetch_example{method=GET, path="/"}
│ ├─588ms DEBUG Response received from example, backend=example, status=200 OK, cache_status=HIT
│ ├─┐open_datastore{name="subscriptions"}
│ ├─┘
│ ├─┐read_from_datastore{key="foo@example.com"}
│ │ ├─  0ms  WARN Item found, key=foo@example.com
│ ├─┘
├─┘
├─  4s  TRACE Returning response, status=200 OK
┘

I would like to propose adding a configuration mode that allows for higher time precision with decimals in the output. The output with the proposed changes would look like this:

┐run{hostname="localhost"}
├─ 45.96μs TRACE Request received
├─┐fetch_httpbin{method=GET, path="/"}
│ ├─ 3.70s  DEBUG Response received, backend=httpbin, status=200 OK, cache_status=MISS
├─┘
├─┐fetch_example{method=GET, path="/"}
│ ├─ 587.93ms DEBUG Response received from example, backend=example, status=200 OK, cache_status=HIT
│ ├─┐open_datastore{name="subscriptions"}
│ ├─┘
│ ├─┐read_from_datastore{key="foo@example.com"}
│ │ ├─ 43.04μs  WARN Item found, key=foo@example.com
│ ├─┘
├─┘
├─ 4.29s  TRACE Returning response, status=200 OK
┘