-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Sentry tracing and supporting ring middleware.
Big thanks to @karuta0825 for the tracing functionality! Update Sentry Java SDK to 5.7.1. Various library updates. Fixes #32. -=david=-
- Loading branch information
Showing
19 changed files
with
543 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{:paths ["src" "resources"] | ||
|
||
:deps {org.clojure/clojure {:mvn/version "1.10.3"} | ||
;; | ||
;; | ||
;; | ||
ch.qos.logback/logback-classic {:mvn/version "1.2.11"} | ||
integrant/integrant {:mvn/version "0.8.0"} | ||
integrant/repl {:mvn/version "0.3.2"} | ||
io.sentry/sentry {:mvn/version "5.7.1"} | ||
io.sentry/sentry-clj {:local/root "../../../sentry-clj"} | ||
org.clojure/tools.cli {:mvn/version "1.0.206"} | ||
org.clojure/tools.logging {:mvn/version "1.2.4"} | ||
org.slf4j/jcl-over-slf4j {:mvn/version "1.7.36"} | ||
org.slf4j/jul-to-slf4j {:mvn/version "1.7.36"} | ||
org.slf4j/log4j-over-slf4j {:mvn/version "1.7.36"} | ||
org.slf4j/slf4j-api {:mvn/version "1.7.36"} | ||
ring/ring-core {:mvn/version "1.9.5"} | ||
ring/ring-jetty-adapter {:mvn/version "1.9.5"} | ||
ring/ring-json {:mvn/version "0.5.1"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration scan="true" scanPeriod="10 seconds"> | ||
|
||
<statusListener class="ch.qos.logback.core.status.NopStatusListener" /> | ||
|
||
<contextName>examples.basic</contextName> | ||
|
||
<variable name="ROOT_LOG_LEVEL" value="${ROOT_LOG_LEVEL:-info}" /> | ||
|
||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<Pattern>[%boldWhite(%d)] --- [%boldBlue(%-5level)][%boldGreen(%-25.25logger{25})] - %msg%n%rEx</Pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="${ROOT_LOG_LEVEL}"> | ||
<appender-ref ref="CONSOLE"/> | ||
</root> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
(ns ring-with-tracing.main | ||
(:require | ||
[integrant.core :as ig] | ||
[ring.adapter.jetty :refer [run-jetty]] | ||
[ring.middleware.json :refer [wrap-json-params wrap-json-response]] | ||
[ring.middleware.keyword-params :refer [wrap-keyword-params]] | ||
[sentry-clj.core :as sentry] | ||
[sentry-clj.ring :refer [wrap-report-exceptions wrap-sentry-tracing]] | ||
[sentry-clj.tracing :refer [with-start-child-span]])) | ||
|
||
(def config | ||
{:adapter/jetty {:port 8080, :handler (ig/ref :handler/router)} | ||
:handler/router {:app (ig/ref :handler/hello)} | ||
:handler/hello {:name "Sentry"}}) | ||
|
||
(defmethod ig/init-key :adapter/jetty [_ {:keys [handler] :as opts}] | ||
(run-jetty handler (-> opts (dissoc :handler) (assoc :join? false)))) | ||
|
||
(defmethod ig/init-key :handler/hello [_ {:keys [name]}] | ||
(fn [request] | ||
|
||
(with-start-child-span "task" "my-child-operation" | ||
(Thread/sleep 1000)) | ||
|
||
{:status 200 | ||
:headers {"Content-type" "application/json"} | ||
:body (str "Hi " name)})) | ||
|
||
(defmethod ig/init-key :handler/router [_ {:keys [app]}] | ||
;; set your dsn | ||
(let [dsn "https://abcdefg@localhost:9000/2"] | ||
(sentry/init! dsn {:dsn dsn | ||
:environment "local" | ||
:traces-sample-rate 1.0 | ||
:debug true})) | ||
|
||
(-> app | ||
(wrap-report-exceptions {}) | ||
wrap-sentry-tracing | ||
wrap-keyword-params | ||
wrap-json-params | ||
wrap-json-response)) | ||
|
||
(defmethod ig/halt-key! :adapter/jetty [_ server] | ||
(.stop server)) | ||
|
||
(defn -main | ||
[& _] | ||
(-> config | ||
ig/init)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns user | ||
(:require | ||
[integrant.core :as ig] | ||
[integrant.repl :refer [clear go halt prep init reset reset-all]] | ||
[ring-with-tracing.main])) | ||
|
||
(integrant.repl/set-prep! (comp ig/prep (constantly ring-with-tracing.main/config))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.