Skip to content

Commit

Permalink
Add usage explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
valerauko committed Nov 20, 2023
1 parent 25df413 commit 3167157
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,22 @@ Utility function that builds Datadog headers for distributed tracing. By adding
;; (:require [sleepy.dog :as datadog])
(merge (datadog/http-headers) headers)
```

### `report-error!`

Used to manually report caught exceptions (without relying on the automatic reporting from `with-tracing` or `defn-traced`). This can be useful for example in a Ring handler that catches all escaped exceptions are responds with a well-formed 500 error.

```clj
(defn wrap-exception
[handler]
(fn exception-catcher
[request]
(try
(handler request)
(catch Throwable ex
(let [span (datadog/active-span!)]
(datadog/report-error! span ex)
(when-let [root (datadog/root-of span)]
(datadog/report-error! root ex)))
{:status 500 :body (.getMessage ex)}))))
```

0 comments on commit 3167157

Please # to comment.