Skip to content

Commit

Permalink
[mod] [BREAKING] NB v3 core, use Telemere signal engine (~wip)
Browse files Browse the repository at this point in the history
TODO Commit info
  • Loading branch information
ptaoussanis committed Oct 31, 2024
1 parent a308a7e commit a2a3e2f
Show file tree
Hide file tree
Showing 9 changed files with 1,254 additions and 1,866 deletions.
21 changes: 9 additions & 12 deletions examples/clj/src/example/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@
simple ongoing application performance monitoring.
Note that a similar pattern can also be used for Cljs apps.
See the Tufte README for more info!"

{:author "Peter Taoussanis (@ptaoussanis)"}
(:require
[clojure.string :as str]
[ring.middleware.defaults]
[ring.adapter.jetty]
[compojure.core :as comp :refer (defroutes GET POST)]
[compojure.core :as comp :refer [defroutes GET POST]]
[compojure.route :as route]
[hiccup.core :as hiccup]
[taoensso.encore :as enc :refer (have have?)]
[taoensso.encore :as enc :refer [have have?]]
[taoensso.tufte :as tufte]))

(enc/defonce stats-accumulator
"On eval, will register a Tufte handler to accumulate the results from
all unfiltered `profile` data. Deref this to get the accumulated data.
(tufte/profile {:id :endpoint1} ...)
(tufte/profile {:id :endpoint2} ...)
...
@stats-accumulator => Return accumulated performance stats"
"Accumulates results from all unfiltered `profile` calls.
Deref this to get the accumulated data."
(tufte/stats-accumulator))

(tufte/add-accumulating-handler! {:ns-pattern "*"}))
;; Register handler for `profile` results
(tufte/add-handler! :my-accumulating-handler
(tufte/accumulating-handler stats-accumulator)
{:ns-filter "*"})

(defroutes ring-routes
(GET "/" ring-req
Expand Down
5 changes: 3 additions & 2 deletions examples/cljs/src/example/hello.cljs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(ns example.hello
(:require [taoensso.tufte :as tufte
:refer-macros (defnp p profiled profile)]))
:refer [defnp p profiled profile]]))

(tufte/add-basic-println-handler! {})
(tufte/add-handler! :my-print-handler
(tufte/print-handler))

(defn get-x [] (+ 1 1))
(defn get-y [] (+ 2 2))
Expand Down
14 changes: 6 additions & 8 deletions examples/readme_examples.cljc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
(ns readme-examples
"Basic examples that appear in the Truss README."
(:require [taoensso.tufte]))
(:require [taoensso.tufte :as tufte]))

(comment

(taoensso.tufte/refer-tufte) ; Setup Tufte's ns imports (works with clj only)
(taoensso.tufte/add-basic-println-handler! {}) ; Send `profile` stats to `println`
(tufte/refer-tufte) ; Setup Tufte's ns imports
(tufte/add-handler! :my-print-handler
(tufte/print-handler)) ; Send `profile` stats to `print`

;;; Let's define a couple dummy fns to simulate doing some expensive work
(defn get-x [] (Thread/sleep 500) "x val")
Expand All @@ -31,11 +32,8 @@

(comment

(ns my-clj-ns ; Clojure namespace
(:require [taoensso.tufte :as tufte :refer (defnp p profiled profile)]))

(ns my-cljs-ns ; ClojureScript namespace
(:require [taoensso.tufte :as tufte :refer-macros (defnp p profiled profile)]))
(ns my-ns
(:require [taoensso.tufte :as tufte :refer [defnp p profiled profile]]))

)

Expand Down
Loading

0 comments on commit a2a3e2f

Please sign in to comment.