guys, when the information is sent the "NAME" parameter is going as GET, POST and the like... How do I put "GET: /route"? Without using the common span but the http...
The name and semantic attributes of existing HTTP server spans can be updated when the route is known. To set the route data for an existing server span, use the function add-route-data! as covered by https://cljdoc.org/d/com.github.steffan-westcott/clj-otel-api/0.1.5/doc/guides#_manually_add_route_data_to_a_server_span, or (coming in the next clj-otel release) use https://github.com/steffan-westcott/clj-otel/blob/ab16943e0fa9a327a8fd8da4f1f890d2abe92619/clj-otel-api/src/steffan_westcott/clj_otel/api/trace/http.clj#L272 middleware for Ring. The examples show how wrap-route can be https://github.com/steffan-westcott/clj-otel/blob/ab16943e0fa9a327a8fd8da4f1f890d2abe92619/examples/common-utils/middleware/src/example/common_utils/middleware.clj#L34.
I tried to use this function, but I always fall into the same error... java.lang.ClassCastException at / io.opentelemetry.api.trace.PropagatedSpan cannot be cast to clojure.lang.IFn
Can you share the code you wrote? It may be a simple syntax error, like using parentheses ( ) where they should not be. In Clojure using ( ) means functional call.
I managed to do!!
Just one point, I got to where I would like to change... Today, the lib allows doing this for known routes, correct? In this case, an application with 300, 500, 1000 routes... You would have to configure one by one. Today, is there a way to automate this? this is my idea lol
I'm glad you've figured it out. As you've probably found for yourself, the Clojure code to execute should be in the correct place. You are using Compojure macros to create your handlers, here is a minimal example:
(ns example.hello
(:require [compojure.core :refer :all]
[ring.adapter.jetty :as jetty]
[steffan-westcott.clj-otel.api.trace.http :as trace-http]))
(defroutes
hello-routes
(GET "/user/:id" [id]
(do
(trace-http/add-route-data! "/user/:id")
(str "<h1>Hello user " id "</h1>"))))
(defonce
server
(jetty/run-jetty #'hello-routes
{:port 8080
:join? false}))Compojure does not expose the matched route as data, unfortunately. If this is a problem, I suggest using Reitit instead, a very popular HTTP router, which does expose the route as data. The upcoming clj-otel release includes a wrap-route middleware, which together with Reitit automates the setting of route data on HTTP server spans.
perfect, if the next version will already do that, my problem will be solved.
Steffan, thank you very much for your attention, sorry for all the inconvenience. You are amazing.