Skip to content

Print traces waterfall style to the console #71

@cjohansen

Description

@cjohansen

When you have multiple levels of tracing telemere's default console logger prints them in the order they are started, which results in traces printing in the reverse order they appear in source code. Maybe telemere could provide a buffering handler that could print traces in a waterfall like how tools such as Jaeger print nested spans in traces?

Here's some code I just wrote:

(defn receive [ctx req]
  (tel/trace!
   ::receive-command
   (let [command (prepare-command req)
         res (validate-command req command)]
     (tel/trace!
      {:id ::validated-command
       :data res}
      (if (:valid? res)
        (let [execution (process-command ctx (:state req) command)]
          (tel/trace!
           {:id ::executed-command
            :data execution}
           (if (:execution/success? execution)
             (:execution/result execution)
             (render-error req 500))))
        (render-error req (:status res)))))))

This prints like so:

14:59:49 INFO TRACE pairsmith.commands[97,6] ::executed-command ...
14:59:49 INFO TRACE pairsmith.commands[97,6] ::validated-command ...
14:59:49 INFO TRACE pairsmith.commands[93,3] ::receive-command ...

I'd like them to print something like this:

14:59:49 INFO TRACE pairsmith.commands[93,3] ::receive-command ...
   14:59:49 INFO TRACE pairsmith.commands[97,6] ::validated-command ...
      14:59:49 INFO TRACE pairsmith.commands[97,6] ::executed-command ...

I'm not exactly sure about the details - e.g. where to indent etc, but seeing them in the order they appear in the code would be helpful, and some visual clues that they are part of the same flow would also be nice.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions