@devurandom I've added new middleware wrap-span and wrap-bound-span and updated the microservices examples to demonstrate recording of uncaught exceptions in https://github.com/steffan-westcott/clj-otel/commit/66e2447cc11c997b9b762696ce2a44a51180bbbd
Thanks! I'll more closely examine the behaviour with regards to different modes of launching the application.
> How are you launching your application?
I start an nREPL using clojure with an alias from a compose file, and then connect and start HTTP server (via a user/go function) from Cursive.
Thanks! I'm using that code now in our service (copied it, until there is a clj-otel release) and so far it seems to work well!
One issue I noticed is that code.file.path and code.line.number point at the wrap-span function (because they are inserted by the with-span! macro) and are thus not very useful.
Then I tried inserting the middleware into the stack, with:
(defmacro span-opts-fn
[span-name-fn]
`(fn [request#]
{:name (~span-name-fn request#)
:source {:line ~(:line (meta &form))
:file ~*file*}}))
,,,
#(trace-span/wrap-span % (span-opts-fn (fn [{:keys [request-method uri]
{route :template} :reitit.core/match}]
(format "handle %s %s" (str/upper-case (name request-method)) (or route uri)))))
The source map part is copied straight from steffan-westcott.clj-otel.api.trace.span/with-span!. This gives me a more useful file/line reference in the trace.
But now I have a different oddity: Without overriding source, the code.file.path I see in OTel (Azure.Dashboard) is "nice", relative to the classpath. But when overriding source in my own code, I get an "ugly", absolute path. Any idea how to get both? Both a nice, short path, and file/line pointing to the place where I insert my middleware?You may need to review how your application is launched. I've noticed that processes launched with the clojure or java command, *file* always gives the resource file path. On the other hand, processes launched with the IntelliJ/Cursive process launcher, *file* gives the absolute file path. I've also noticed that files read from JAR files on the classpath will always give resource file paths.
I don't fully understand this behaviour, this is based from observations.
How are you launching your application?