taoensso / telemere

Structured telemetry library for Clojure/Script
https://www.taoensso.com/telemere
Eclipse Public License 1.0
199 stars 5 forks source link

Consider allowing forms within `with-ctx` and `with-ctx+` #31

Closed rschmukler closed 4 weeks ago

rschmukler commented 1 month ago

Currently you can only use a single form inside with-ctx and its sibling. Generally, with-* forms are variadic.

ie. I would expect the following to work:

(tel/with-ctx+ {:foo "bar"}
  (tel/log! "Something with context")
  (tel/log! "Something else with context"))
ptaoussanis commented 1 month ago

Hi Ryan-

That's a totally reasonable expectation, though the current limitation is actually intentional. I'm not generally a fan of variadic & body signatures, though I understand that they're very common in Clojure.

The main downside is that they completely shut the door to possible future extensions to arity, and their only upside is avoiding a (do ...) - which I don't believe is a big deal in practice.

I have however seen numerous cases where prematurely choosing an & body sig led to regret later.

Can of course always change this later if/when we're very confident that there'll be no desire to extend to other arities. But in the meantime I'd prefer to keep this door open, especially while the library is new.

Hope that makes sense?