sentry-clj icon indicating copy to clipboard operation
sentry-clj copied to clipboard

traces-sample-fn not being called

Open piero opened this issue 4 years ago • 0 comments

Environment

  • Clojure 1.11.1
  • sentry-clj 6.4.185

Steps to Reproduce

(defn traces-sampler
  [{:keys [custom-sample-context transaction-context]}]
  (println "-> custom-sample-context:" custom-sample-context)
  (println "-> transaction-context:" transaction-context)
  0.1)

(sentry/init! config/sentry-endpoint
              {:server-name              config/application-name
               :environment              config/environment
               :traces-sample-fn         traces-sampler
               :uncaught-handler-enabled true
               :before-send-fn           (fn [^SentryEvent event ^Hint _hint]
                                           (println (format "[%s] Reporting to Sentry: %s"
                                                            (str (.getLevel event))
                                                            (.getMessage (.getMessage event))))
                                           event)})

(sentry/send-event
      {:message     "This is a test"
       :server-name config/application-name
       :level       :error
       :throwable   (Exception. "Boom!")})

Expected Result

I should see the output of

  (println "-> custom-sample-context:" custom-sample-context)
  (println "-> transaction-context:" transaction-context)

Actual Result

I don't see that output. It looks like the traces-sampler function is not being called. Am I defining the traces-sampler function correctly? Couldn't find any examples for it, so just guessed from the source code. Thank you.

piero avatar Oct 18 '22 15:10 piero