You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following middleware adds route information to spans when using Compojure:
(nssteffan-westcott.clj-otel.api.trace.http
(:require
[compojure.core :as compojure]))
(defnwrap-compojure-route"Ring middleware to add matched Compojure route to the server span and Ring request map."
[handler]
(compojure/wrap-routes handler (fn [route-handler]
(trace-http/wrap-route route-handler (comp second :compojure/route)))))
It can be used in the same way as steffan-westcott.clj-otel.api.trace.http/wrap-reitit-route.
To avoid adding a dependency on Compojure for projects that do not use it, some optional-require mechanism would be needed. I don't know how people commonly do that, but the following seems to work:
(nssteffan-westcott.clj-otel.api.trace.http)
(defwrap-compojure-route"Ring middleware to add matched Compojure route to the server span and Ring request map."
(try
(when-let [compojure-core-wrap-routes (requiring-resolve 'compojure.core/wrap-routes)]
(fn [handler]
(compojure-core-wrap-routes handler (fn [route-handler]
(trace-http/wrap-route route-handler (comp second :compojure/route))))))
;; `requiring-resolve` throws `java.io.FileNotFoundException` when the namespace cannot be required:
(catch Exception _)))
The text was updated successfully, but these errors were encountered:
The following middleware adds route information to spans when using Compojure:
It can be used in the same way as
steffan-westcott.clj-otel.api.trace.http/wrap-reitit-route
.To avoid adding a dependency on Compojure for projects that do not use it, some optional-require mechanism would be needed. I don't know how people commonly do that, but the following seems to work:
The text was updated successfully, but these errors were encountered: