taoensso / telemere

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

log! doesn't compile inside clojurescript go block #21

Closed aiba closed 2 months ago

aiba commented 2 months ago

Compiling this code in ClojureScript fails with "ExceptionInfo Can't call nil":

(cljs.core.async/go (taoensso.telemere/log! "hello"))

I'm guessing this has something to do with the way the log! macro expands and then the go macro analyzes the expanded code.

On JVM clojure, it works fine. Is there a way to get it to also work in ClojureScript?

ptaoussanis commented 2 months ago

@aiba Hi Aaron, thanks for the report! I'll need to investigate what go is doing that might be causing trouble.

What's the urgency on this? Could a fix wait till next week sometime?

aiba commented 2 months ago

Not urgent. For now, I can just wrap log! in a regular function, since go macros don't analyze across function boundaries.

ptaoussanis commented 2 months ago

Okay, thanks!

BTW in case it's not obvious, you may literally be able to do something like ((fn [] (tel/log! "hello"))) within your go block. (Not sure if that's what you already had in mind, or if you were talking about moving your log calls into a fn that you def outside your go block).

I'll keep this open till I've investigated and found a solution 👍

ptaoussanis commented 2 months ago

Update: fix (a reasonable workaround) is up on master, and available now as a 1.0.0-SNAPSHOT.

Basically just auto-wrapping Cljs expansions with ((fn [] ...)) to avoid fiddling by go and other similar IOC-style mechanisms.

Will keep this issue open until beta 23 is released (ETA next week).

aiba commented 2 months ago

Oh wow that's a nifty trick I hadn't thought of for go blocks, thank you for that! That's going to be useful to have in many situations.

ptaoussanis commented 2 months ago

Closing since this is now addressed in the latest betas 👍