mirror of
https://github.com/taoensso/telemere.git
synced 2026-02-27 12:12:24 +00:00
Compare commits
No commits in common. "master" and "v1.1.0" have entirely different histories.
13 changed files with 144 additions and 216 deletions
57
CHANGELOG.md
57
CHANGELOG.md
|
|
@ -1,57 +1,6 @@
|
|||
This project uses [**Break Versioning**](https://www.taoensso.com/break-versioning).
|
||||
|
||||
---
|
||||
|
||||
# `v1.2.1` (2025-12-16)
|
||||
|
||||
## 📦 Dependencies
|
||||
|
||||
Available on Clojars:
|
||||
|
||||
1. [Telemere](https://clojars.org/com.taoensso/telemere/versions/1.2.1) - main dep
|
||||
2. [SLF4J provider](https://clojars.org/com.taoensso/telemere-slf4j/versions/1.2.1) - extra dep to [send Java logging](https://github.com/taoensso/telemere/wiki/3-Config#java-logging) to Telemere
|
||||
|
||||
This project uses [Break Versioning](https://www.taoensso.com/break-versioning).
|
||||
|
||||
## Release notes
|
||||
|
||||
This is a **hotfix release** to fix a regression in v1.2.0 that prevented errors from correctly appearing via the Timbre->Telemere appender.
|
||||
|
||||
This should be a safe upgrade for users of v1.2.0, apologies for the trouble! - Peter Taoussanis
|
||||
|
||||
---
|
||||
|
||||
# `v1.2.0` (2025-12-09)
|
||||
|
||||
## 📦 Dependencies
|
||||
|
||||
Available on Clojars:
|
||||
|
||||
1. [Telemere](https://clojars.org/com.taoensso/telemere/versions/1.2.0) - main dep
|
||||
2. [SLF4J provider](https://clojars.org/com.taoensso/telemere-slf4j/versions/1.2.0) - extra dep to [send Java logging](https://github.com/taoensso/telemere/wiki/3-Config#java-logging) to Telemere
|
||||
|
||||
This project uses [Break Versioning](https://www.taoensso.com/break-versioning).
|
||||
|
||||
## Release notes
|
||||
|
||||
This is a **maintenance and feature release** that should be a safe upgrade for users of v1.1.x, though there have been a few small **changes to signal content** relevant to a very small number of users (see the ➤ items below).
|
||||
|
||||
Please **report any unexpected problems** on [GitHub](https://github.com/taoensso/telemere/issues) or the [Slack channel](https://www.taoensso.com/telemere/slack) 🙏 - [Peter Taoussanis](https://www.taoensso.com)
|
||||
|
||||
## Since `v1.1.0` (2025-08-22)
|
||||
|
||||
- ➤ **\[mod]** SLF4J->Telemere backend: move noisy stuff out of signal data \[e6ce33d]
|
||||
- ➤ **\[mod]** Timbre shim API: move noisy `:vargs` out of signal data \[cc680b0
|
||||
- \[mod] [fix] Timbre->Telemere appender: de-duplicate output formatting \[47af803]
|
||||
- \[mod] [fix] Timbre->Telemere appender: fix callsite coords \[b56e1c4]
|
||||
- \[fix] OpenTelemetry handler: add missing line info to output \[6155713]
|
||||
- \[fix] Correctly handle nil `:run` opt \[8a3ae14]
|
||||
- \[new] OpenTelemetry handler: support spans created outside Telemere \[a6fc4ad]
|
||||
- \[new] [#68] Add config to skip host and/or thread info \[a883df3]
|
||||
- \[doc] Clarify that signal content is lazy \[917b1b4]
|
||||
|
||||
---
|
||||
|
||||
# `v1.1.0` (2025-08-22)
|
||||
|
||||
## 📦 Dependencies
|
||||
|
|
@ -59,17 +8,15 @@ Please **report any unexpected problems** on [GitHub](https://github.com/taoenss
|
|||
Available on Clojars:
|
||||
|
||||
1. [Telemere](https://clojars.org/com.taoensso/telemere/versions/1.1.0) - main dep
|
||||
2. [SLF4J provider](https://clojars.org/com.taoensso/telemere-slf4j/versions/1.1.0) - extra dep to [send Java logging](https://github.com/taoensso/telemere/wiki/3-Config#java-logging) to Telemere
|
||||
2. [SLF4J provider](https://clojars.org/com.taoensso/telemere-slf4j/versions/1.0.1) - extra dep to [send Java logging](https://github.com/taoensso/telemere/wiki/3-Config#java-logging) to Telemere
|
||||
|
||||
This project uses [Break Versioning](https://www.taoensso.com/break-versioning).
|
||||
|
||||
## Release notes
|
||||
|
||||
This is a **maintenance release** that fixes a few minor issues, improves docs, and adds some extra API flexibility. It should be a safe upgrade for all users of v1.x.
|
||||
|
||||
Please **report any unexpected problems** on [GitHub](https://github.com/taoensso/telemere/issues) or the [Slack channel](https://www.taoensso.com/telemere/slack) 🙏 - [Peter Taoussanis](https://www.taoensso.com)
|
||||
|
||||
## Since v1.0.1 (2025-05-27)
|
||||
## Since v1.0.01 (2025-05-27)
|
||||
|
||||
- \[fix] `:trace` level JS console logging \[b2a8b66]
|
||||
- \[fix] Clj-kondo warnings for `with-signal/s` \[269c58d]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<a href="https://www.taoensso.com/clojure" title="More stuff by @ptaoussanis at www.taoensso.com"><img src="https://www.taoensso.com/open-source.png" alt="Taoensso open source" width="340"/></a>
|
||||
[**API**][cljdoc] | [**Wiki**][GitHub wiki] | [Slack][] | Latest release: [v1.2.1](../../releases/tag/v1.2.1) (2025-12-16)
|
||||
[**API**][cljdoc] | [**Wiki**][GitHub wiki] | [Slack channel][] | Latest release: [v1.1.0](../../releases/tag/v1.1.0) (2025-08-22)
|
||||
|
||||
[![Clj tests][Clj tests SVG]][Clj tests URL]
|
||||
[![Cljs tests][Cljs tests SVG]][Cljs tests URL]
|
||||
|
|
@ -200,7 +200,7 @@ See [examples.cljc](https://github.com/taoensso/telemere/blob/master/examples.cl
|
|||
## Comparisons
|
||||
|
||||
- Telemere [compared](../../wiki/5-Migrating#from-timbre) to [Timbre](https://www.taoensso.com/timbre) (Telemere's predecessor)
|
||||
- Telemere [compared](../../wiki/6-FAQ#how-does-telemere-compare-to-%CE%BClog) to [μ/log](https://github.com/BrunoBonacci/mulog) (structured micro-logging library)
|
||||
- Telemere [compared](../../wiki/6-FAQ#how-does-telemere-compare-to-mulog) to [μ/log](https://github.com/BrunoBonacci/mulog) (structured micro-logging library)
|
||||
|
||||
## Videos
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ See [here](../../wiki/8-Community) for community resources.
|
|||
- [Wiki][GitHub wiki] (getting started, usage, etc.)
|
||||
- API reference via [cljdoc][cljdoc]
|
||||
- Extensive [internal help](#internal-help) (no need to leave your IDE)
|
||||
- Support via [Slack][] or [GitHub issues][]
|
||||
- Support via [Slack channel][] or [GitHub issues][]
|
||||
- [General observability tips](../../wiki/7-Tips) (advice on building and maintaining observable Clojure/Script systems, and getting the most out of Telemere)
|
||||
|
||||
## Funding
|
||||
|
|
@ -331,7 +331,7 @@ Licensed under [EPL 1.0](LICENSE.txt) (same as Clojure).
|
|||
[GitHub releases]: ../../releases
|
||||
[GitHub issues]: ../../issues
|
||||
[GitHub wiki]: ../../wiki
|
||||
[Slack]: https://www.taoensso.com/telemere/slack
|
||||
[Slack channel]: https://www.taoensso.com/telemere/slack
|
||||
|
||||
[Peter Taoussanis]: https://www.taoensso.com
|
||||
[sponsor]: https://www.taoensso.com/sponsor
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 340 KiB After Width: | Height: | Size: 384 KiB |
Binary file not shown.
|
|
@ -1,4 +1,4 @@
|
|||
(defproject com.taoensso/telemere "1.2.1"
|
||||
(defproject com.taoensso/telemere "1.1.0"
|
||||
:author "Peter Taoussanis <https://www.taoensso.com>"
|
||||
:description "Structured logs and telemetry for Clojure/Script"
|
||||
:url "https://www.taoensso.com/telemere"
|
||||
|
|
@ -10,15 +10,15 @@
|
|||
:scm {:name "git" :url "https://github.com/taoensso/telemere"}
|
||||
|
||||
:dependencies
|
||||
[[com.taoensso/encore "3.159.0"]]
|
||||
[[com.taoensso/encore "3.153.1"]]
|
||||
|
||||
:test-paths ["test" #_"src"]
|
||||
|
||||
:profiles
|
||||
{;; :default [:base :system :user :provided :dev]
|
||||
:provided {:dependencies [[org.clojure/clojurescript "1.12.134"]
|
||||
:provided {:dependencies [[org.clojure/clojurescript "1.12.42"]
|
||||
[org.clojure/clojure "1.11.4"]]}
|
||||
:c1.12 {:dependencies [[org.clojure/clojure "1.12.3"]]}
|
||||
:c1.12 {:dependencies [[org.clojure/clojure "1.12.1"]]}
|
||||
:c1.11 {:dependencies [[org.clojure/clojure "1.11.4"]]}
|
||||
:c1.10 {:dependencies [[org.clojure/clojure "1.10.3"]]}
|
||||
|
||||
|
|
@ -47,18 +47,18 @@
|
|||
|
||||
:dependencies
|
||||
[[org.clojure/core.async "1.8.741"]
|
||||
[org.clojure/test.check "1.1.2"]
|
||||
[org.clojure/test.check "1.1.1"]
|
||||
[org.clojure/tools.logging "1.3.0"]
|
||||
[org.slf4j/slf4j-api "2.0.17"]
|
||||
[com.taoensso/telemere-slf4j "1.2.1"]
|
||||
[com.taoensso/telemere-slf4j "1.1.0"]
|
||||
#_[org.slf4j/slf4j-simple "2.0.16"]
|
||||
#_[org.slf4j/slf4j-nop "2.0.16"]
|
||||
#_[io.github.paintparty/bling "0.4.2"]
|
||||
|
||||
;;; For optional handlers
|
||||
[io.opentelemetry/opentelemetry-api "1.57.0"]
|
||||
[io.opentelemetry/opentelemetry-sdk-extension-autoconfigure "1.57.0"]
|
||||
[io.opentelemetry/opentelemetry-exporter-otlp "1.57.0"]
|
||||
[io.opentelemetry/opentelemetry-api "1.53.0"]
|
||||
[io.opentelemetry/opentelemetry-sdk-extension-autoconfigure "1.53.0"]
|
||||
[io.opentelemetry/opentelemetry-exporter-otlp "1.53.0"]
|
||||
#_[io.opentelemetry/opentelemetry-exporters-jaeger "0.9.1"]
|
||||
[metosin/jsonista "0.3.13"]
|
||||
[com.draines/postal "2.0.5"]
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ All options are available for all signal creator calls:
|
|||
Defaults to `:auto` for tracing signals, and nil otherwise
|
||||
|
||||
`:msg` --------- Arb app-level ?message to incl. in signal: str or vec of strs to join (with `\space`), may be a delay
|
||||
`:data` -------- Arb app-level ?data to incl. in signal: usu. a map, LAZY! [3]
|
||||
`:data` -------- Arb app-level ?data to incl. in signal: usu. a map
|
||||
`:error` ------- Arb app-level ?error to incl. in signal: platform error [2]
|
||||
|
||||
`:run` --------- ?form to execute UNCONDITIONALLY; will incl. `:run-val` in signal
|
||||
`:do` ---------- ?form to execute conditionally (iff signal allowed) and LAZILY [3], before establishing `:let` ?binding
|
||||
`:let` --------- ?bindings to establish conditionally (iff signal allowed) and LAZILY [3], BEFORE evaluating `:data` and `:msg` (useful!)
|
||||
`:do` ---------- ?form to execute conditionally (iff signal allowed), before establishing `:let` ?binding
|
||||
`:let` --------- ?bindings to establish conditionally (iff signal allowed), BEFORE evaluating `:data` and `:msg` (useful!)
|
||||
|
||||
`:parent` ------ Custom ?{:keys [id uid]} to override auto (dynamic) parent signal tracing info
|
||||
`:root` -------- Custom ?{:keys [id uid]} to override auto (dynamic) root signal tracing info
|
||||
|
|
@ -37,13 +37,9 @@ All options are available for all signal creator calls:
|
|||
|
||||
<kvs> ---------- Other arb app-level ?kvs to incl. in signal. Typically NOT included in
|
||||
handler output, so a great way to provide custom data/opts for use
|
||||
(only) by custom transforms/handlers. LAZY! [3]
|
||||
(only) by custom transforms/handlers.
|
||||
|
||||
If anything is unclear, please ping me (@ptaoussanis) so that I can improve these docs!
|
||||
|
||||
[1] `java.time.Instant` or `js/Date`
|
||||
[2] `java.lang.Throwable` or `js/Error`
|
||||
[3] Most Telemere signal content is evaluated CONDITIONALLY (iff signal allowed),
|
||||
LAZILY (when signal is created), and on the HANDLING THREAD (not logging thread).
|
||||
This allows efficient filtering, better control+monitoring of back pressure,
|
||||
conditional effects, etc. Ref. <https://www.taoensso.com/telemere/flow> for visual!
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
(remove-ns (symbol (str *ns*)))
|
||||
(:api (enc/interns-overview)))
|
||||
|
||||
(enc/assert-min-encore-version [3 159 0])
|
||||
(enc/assert-min-encore-version [3 153 1])
|
||||
|
||||
;;;; Shared signal API
|
||||
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@
|
|||
(def enabled:otel-tracing?
|
||||
"Documented at `taoensso.telemere/otel-tracing?`."
|
||||
(enc/get-env {:as :bool, :default present:otel?}
|
||||
:taoensso.telemere/otel-tracing<.platform>))
|
||||
|
||||
(def enabled:incl-host-info? "Include `:host` info in signals by default?" (enc/get-env {:as :bool, :default true} :taoensso.telemere/incl-host-info))
|
||||
(def enabled:incl-thread-info? "Include `:thread` info in signals by default?" (enc/get-env {:as :bool, :default true} :taoensso.telemere/incl-thread-info))))
|
||||
:taoensso.telemere/otel-tracing<.platform>))))
|
||||
|
||||
(def uid-kind
|
||||
"Documented at `taoensso.telemere/*uid-fn*`."
|
||||
|
|
@ -173,8 +170,8 @@
|
|||
(defn default-trace-msg
|
||||
[form value error nsecs]
|
||||
(if error
|
||||
(str (if (nil? form) "nil" form) " !> " (truss/ex-type error))
|
||||
(str (if (nil? form) "nil" form) " => " (if (nil? value) "nil" value))))
|
||||
(str form " !> " (truss/ex-type error))
|
||||
(str form " => " value)))
|
||||
|
||||
(comment
|
||||
(default-trace-msg "(+ 1 2)" 3 nil 12345)
|
||||
|
|
@ -527,16 +524,14 @@
|
|||
clj? (not cljs?)
|
||||
|
||||
opts (merge {:kind :generic, :level :info} base-opts opts)
|
||||
|
||||
run-form? (contains? opts :run)
|
||||
run-form (get opts :run)
|
||||
{run-form :run} opts
|
||||
|
||||
ns-form* (get opts :ns :auto)
|
||||
ns-form (auto-> ns-form* (str *ns*))
|
||||
|
||||
show-run-val (get opts :run-val '_run-val)
|
||||
show-run-form
|
||||
(when run-form?
|
||||
(when run-form
|
||||
(get opts :run-form
|
||||
(if (and
|
||||
(enc/list-form? run-form)
|
||||
|
|
@ -569,15 +564,15 @@
|
|||
id-form :id
|
||||
level-form :level} opts
|
||||
|
||||
trace? (get opts :trace? run-form?)
|
||||
trace? (get opts :trace? (boolean run-form))
|
||||
_
|
||||
(when-not (contains? #{true false nil} trace?)
|
||||
(truss/ex-info!
|
||||
(str "Signal needs compile-time `:trace?` value at "
|
||||
(sigs/format-callsite ns-form coords))))
|
||||
|
||||
host-form (auto-> (get opts :host :auto) (when (and clj? enabled:incl-host-info?) `(enc/host-info)))
|
||||
thread-form (auto-> (get opts :thread :auto) (when (and clj? enabled:incl-thread-info?) `(enc/thread-info)))
|
||||
host-form (auto-> (get opts :host :auto) (when clj? `(enc/host-info)))
|
||||
thread-form (auto-> (get opts :thread :auto) (when clj? `(enc/thread-info)))
|
||||
inst-form (auto-> (get opts :inst :auto) `(enc/now-inst*))
|
||||
|
||||
parent-form (get opts :parent `*trace-parent*)
|
||||
|
|
@ -612,7 +607,7 @@
|
|||
(dissoc opts
|
||||
:elidable? :coords :inst :uid :xfn :xfn+ :kvs+,
|
||||
:sample :ns :kind :id :level :filter :when #_:limit #_:limit-by,
|
||||
:ctx :ctx+ :parent :trace?, :do :let :data :msg :error,
|
||||
:ctx :ctx+ :parent #_:trace?, :do :let :data :msg :error,
|
||||
:run :run-form :run-val, :elide? :allow? #_:callsite-id,
|
||||
:host :thread :otel/context))]
|
||||
|
||||
|
|
@ -624,7 +619,7 @@
|
|||
|
||||
_ ; Compile-time validation
|
||||
(do
|
||||
(when (and run-form? error-form) ; Ambiguous source of error
|
||||
(when (and run-form error-form) ; Ambiguous source of error
|
||||
(truss/ex-info!
|
||||
(str "Signal cannot have both `:run` and `:error` opts at "
|
||||
(sigs/format-callsite ns-form coords))))
|
||||
|
|
@ -636,18 +631,18 @@
|
|||
|
||||
signal-form
|
||||
(let [record-form
|
||||
(let [clause [(if run-form? :run :no-run) (if clj? :clj :cljs)]]
|
||||
(let [clause [(if run-form :run :no-run) (if clj? :clj :cljs)]]
|
||||
(case clause
|
||||
[:run :clj ] `(Signal. 1 ~'__inst ~'__uid, ~'__ns ~coords ~host-form ~'__thread ~'__otel-context, ~sample-form, ~'__kind ~'__id ~'__level, ~ctx-form ~parent-form ~'__root1, ~data-form ~kvs-form ~'_msg_, ~'_run-err '~show-run-form ~show-run-val ~'_end-inst ~'_run-nsecs)
|
||||
[:run :clj ] `(Signal. 1 ~'__inst ~'__uid, ~'__ns ~coords ~host-form ~'__thread ~'__otel-context1, ~sample-form, ~'__kind ~'__id ~'__level, ~ctx-form ~parent-form ~'__root1, ~data-form ~kvs-form ~'_msg_, ~'_run-err '~show-run-form ~show-run-val ~'_end-inst ~'_run-nsecs)
|
||||
[:run :cljs] `(Signal. 1 ~'__inst ~'__uid, ~'__ns ~coords ~sample-form, ~'__kind ~'__id ~'__level, ~ctx-form ~parent-form ~'__root1, ~data-form ~kvs-form ~'_msg_, ~'_run-err '~show-run-form ~show-run-val ~'_end-inst ~'_run-nsecs)
|
||||
[:no-run :clj ] `(Signal. 1 ~'__inst ~'__uid, ~'__ns ~coords ~host-form ~'__thread ~'__otel-context, ~sample-form, ~'__kind ~'__id ~'__level, ~ctx-form ~parent-form ~'__root1, ~data-form ~kvs-form ~msg-form, ~error-form nil nil nil nil)
|
||||
[:no-run :clj ] `(Signal. 1 ~'__inst ~'__uid, ~'__ns ~coords ~host-form ~'__thread ~'__otel-context1, ~sample-form, ~'__kind ~'__id ~'__level, ~ctx-form ~parent-form ~'__root1, ~data-form ~kvs-form ~msg-form, ~error-form nil nil nil nil)
|
||||
[:no-run :cljs] `(Signal. 1 ~'__inst ~'__uid, ~'__ns ~coords ~sample-form, ~'__kind ~'__id ~'__level, ~ctx-form ~parent-form ~'__root1, ~data-form ~kvs-form ~msg-form, ~error-form nil nil nil nil)
|
||||
(truss/ex-info!
|
||||
(str "Unexpected signal constructor args at "
|
||||
(sigs/format-callsite ns-form coords)))))
|
||||
|
||||
record-form
|
||||
(if-not run-form?
|
||||
(if-not run-form
|
||||
record-form
|
||||
`(let [~(with-meta '_run-result {:tag `RunResult}) ~'__run-result
|
||||
~'_run-nsecs (.-run-nsecs ~'_run-result)
|
||||
|
|
@ -679,31 +674,17 @@
|
|||
(do signal#)))))
|
||||
|
||||
;; Trade-off: avoid double `run-form` expansion
|
||||
run-fn-form (when run-form? `(fn [] ~run-form))
|
||||
run-form* (when run-form? `(~'__run-fn-form))
|
||||
run-fn-form (when run-form `(fn [] ~run-form))
|
||||
run-form* (when run-form `(~'__run-fn-form))
|
||||
|
||||
binds-form-base
|
||||
`[~'__inst ~inst-form
|
||||
~'__thread ~thread-form
|
||||
~'__root0 ~root-form0 ; ?{:keys [id uid]}
|
||||
|
||||
~'__otel-context
|
||||
~(when (and clj? enabled:otel-tracing?)
|
||||
(if run-form?
|
||||
`(otel-context+span ~'__id ~'__inst ~(get opts :otel/context `(otel-context)) ~(get opts :otel/span-kind))
|
||||
(do (get opts :otel/context `(otel-context)))))
|
||||
|
||||
~'__uid
|
||||
~(if (and clj? enabled:otel-tracing? trace?)
|
||||
(auto-> uid-form `(or (otel-span-id ~'__otel-context) (com.taoensso.encore.Ids/genHexId16)))
|
||||
(auto-> uid-form `(taoensso.telemere/*uid-fn* (if ~'__root0 false true))))]
|
||||
|
||||
binds-form-more
|
||||
into-let-form
|
||||
(enc/cond!
|
||||
(not trace?) ; Non-tracing signal
|
||||
`[~'__root1 ~'__root0 ; Retain, but don't establish
|
||||
(not trace?) ; Don't trace
|
||||
`[~'__otel-context1 nil
|
||||
~'__uid ~(auto-> uid-form `(taoensso.telemere/*uid-fn* (if ~'__root0 false true)))
|
||||
~'__root1 ~'__root0 ; Retain, but don't establish
|
||||
~'__run-result
|
||||
~(when run-form?
|
||||
~(when run-form
|
||||
`(let [t0# (enc/now-nano*)]
|
||||
(truss/try*
|
||||
(do (RunResult. ~run-form* nil (- (enc/now-nano*) t0#)))
|
||||
|
|
@ -711,9 +692,11 @@
|
|||
|
||||
;; Trace without OpenTelemetry
|
||||
(or cljs? (not enabled:otel-tracing?))
|
||||
`[~'__root1 (or ~'__root0 ~(when trace? `{:id ~'__id, :uid ~'__uid}))
|
||||
`[~'__otel-context1 nil
|
||||
~'__uid ~(auto-> uid-form `(taoensso.telemere/*uid-fn* (if ~'__root0 false true)))
|
||||
~'__root1 (or ~'__root0 ~(when trace? `{:id ~'__id, :uid ~'__uid}))
|
||||
~'__run-result
|
||||
~(when run-form?
|
||||
~(when run-form
|
||||
`(binding [*trace-root* ~'__root1
|
||||
*trace-parent* {:id ~'__id, :uid ~'__uid}]
|
||||
(let [t0# (enc/now-nano*)]
|
||||
|
|
@ -723,17 +706,20 @@
|
|||
|
||||
;; Trace with OpenTelemetry
|
||||
(and clj? enabled:otel-tracing?)
|
||||
`[~'__root1
|
||||
`[~'__otel-context0 ~(get opts :otel/context `(otel-context)) ; Context
|
||||
~'__otel-context1 ~(if run-form `(otel-context+span ~'__id ~'__inst ~'__otel-context0 ~(get opts :otel/span-kind)) ~'__otel-context0)
|
||||
~'__uid ~(auto-> uid-form `(or (otel-span-id ~'__otel-context1) (com.taoensso.encore.Ids/genHexId16)))
|
||||
~'__root1
|
||||
(or ~'__root0
|
||||
~(when trace?
|
||||
`{:id ~'__id, :uid (or (otel-trace-id ~'__otel-context) (com.taoensso.encore.Ids/genHexId32))}))
|
||||
`{:id ~'__id, :uid (or (otel-trace-id ~'__otel-context1) (com.taoensso.encore.Ids/genHexId32))}))
|
||||
|
||||
~'__run-result
|
||||
~(when run-form?
|
||||
`(binding [*otel-context* ~'__otel-context
|
||||
~(when run-form
|
||||
`(binding [*otel-context* ~'__otel-context1
|
||||
*trace-root* ~'__root1
|
||||
*trace-parent* {:id ~'__id, :uid ~'__uid}]
|
||||
(let [otel-scope# (.makeCurrent ~'__otel-context)
|
||||
(let [otel-scope# (.makeCurrent ~'__otel-context1)
|
||||
t0# (enc/now-nano*)]
|
||||
(truss/try*
|
||||
(do (RunResult. ~run-form* nil (- (enc/now-nano*) t0#)))
|
||||
|
|
@ -750,8 +736,11 @@
|
|||
|
||||
(enc/if-not ~allow?
|
||||
~run-form*
|
||||
(let [~@binds-form-base
|
||||
~@binds-form-more
|
||||
(let [~'__inst ~inst-form
|
||||
~'__thread ~thread-form
|
||||
~'__root0 ~root-form0 ; ?{:keys [id uid]}
|
||||
|
||||
~@into-let-form ; Inject conditional bindings
|
||||
signal# ~signal-delay-form]
|
||||
|
||||
(dispatch-signal!
|
||||
|
|
|
|||
|
|
@ -220,14 +220,14 @@
|
|||
(if (or common-attrs trace-attrs)
|
||||
(let [ab (Attributes/builder)]
|
||||
(when-let [ns (get signal :ns)] (.put ab "ns" (str ns)))
|
||||
(when-let [line (enc/get-in* signal [:coords 0])] (.put ab "line" (long line)))
|
||||
(when-let [line (get signal :line)] (.put ab "line" (long line)))
|
||||
(when-let [attrs common-attrs] (put-attrs! ab attrs))
|
||||
(when-let [attrs trace-attrs] (put-attrs! ab attrs))
|
||||
(.build ab))
|
||||
|
||||
;; Common case
|
||||
(when-let [ns (get signal :ns)]
|
||||
(if-let [line (enc/get-in* signal [:coords 0])]
|
||||
(if-let [line (get signal :line)]
|
||||
(Attributes/of ak-ns ns, ak-line (long line))
|
||||
(Attributes/of ak-ns ns)))))))
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
(enc/format* pattern vargs)
|
||||
(enc/str-join " " (map arg-str) vargs)))]
|
||||
|
||||
[error msg vargs])
|
||||
[error msg {:vargs vargs}])
|
||||
|
||||
(let [md (if (and (map? v0) (get (meta v0) :meta)) v0 nil)
|
||||
error (get md :err)
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
(enc/format* pattern vargs)
|
||||
(enc/str-join " " (map arg-str) vargs)))]
|
||||
|
||||
[error msg (when-not (empty? vargs) vargs)])))))
|
||||
[error msg (when-not (empty? vargs) {:vargs vargs})])))))
|
||||
|
||||
(comment
|
||||
(parse-vargs true [ "hello %s" "stu"])
|
||||
|
|
@ -63,13 +63,13 @@
|
|||
[level format-msg? vargs]
|
||||
(truss/keep-callsite
|
||||
`(when (impl/signal-allowed? {:kind :log, :level ~level, :id shim-id})
|
||||
(let [[error# msg# vargs#] (parse-vargs ~format-msg? ~vargs)]
|
||||
(let [[error# msg# data#] (parse-vargs ~format-msg? ~vargs)]
|
||||
(tel/log!
|
||||
{:allow? true
|
||||
:level ~level
|
||||
:id shim-id
|
||||
:error error#
|
||||
:timbre/vargs vargs#}
|
||||
:data data#}
|
||||
msg#)
|
||||
nil)))))
|
||||
|
||||
|
|
@ -190,11 +190,8 @@
|
|||
:min-level nil
|
||||
:fn
|
||||
(fn [data]
|
||||
(let [{:keys [instant level context ?err msg-type vargs
|
||||
?ns-str ?file ?line ?column]} data
|
||||
|
||||
format-msg? (enc/identical-kw? msg-type :f)
|
||||
[_error msg vargs] (parse-vargs format-msg? vargs)]
|
||||
(let [{:keys [instant level context ?err output_
|
||||
?ns-str ?file ?line ?column]} data]
|
||||
|
||||
(taoensso.telemere/signal!
|
||||
{:kind :timbre
|
||||
|
|
@ -203,10 +200,9 @@
|
|||
:ctx+ context
|
||||
|
||||
:ns ?ns-str
|
||||
:coords (when ?line [?line ?column])
|
||||
:file ?file ; Non-standard, goes to kvs
|
||||
:file ?file
|
||||
:line ?line
|
||||
:column ?column
|
||||
|
||||
:error ?err
|
||||
:msg (when msg-type msg)
|
||||
|
||||
:timbre/vargs vargs})))})
|
||||
:msg (force output_)})))})
|
||||
|
|
|
|||
|
|
@ -594,8 +594,7 @@
|
|||
(let [{rv :value, [sv] :signals} (with-sigs (tel/log!? {:allow? false} "msg")) ] [(is (= rv nil)) (is (nil? sv))])])
|
||||
|
||||
(testing "trace!" ; ?id + run => unconditional run result (value or throw)
|
||||
[(let [{rv :value, [sv] :signals} (with-sigs (tel/trace! nil)) ] [(is (= rv nil)) (is (sm? sv {:kind :trace, :coords coords?, :level :info, :id nil, :msg_ "nil => nil"}))])
|
||||
(let [{rv :value, [sv] :signals} (with-sigs (tel/trace! (+ 1 2))) ] [(is (= rv 3)) (is (sm? sv {:kind :trace, :coords coords?, :level :info, :id nil, :msg_ "(+ 1 2) => 3"}))])
|
||||
[(let [{rv :value, [sv] :signals} (with-sigs (tel/trace! (+ 1 2))) ] [(is (= rv 3)) (is (sm? sv {:kind :trace, :coords coords?, :level :info, :id nil, :msg_ "(+ 1 2) => 3"}))])
|
||||
(let [{rv :value, [sv] :signals} (with-sigs (tel/trace! {:msg nil} (+ 1 2))) ] [(is (= rv 3)) (is (sm? sv {:kind :trace, :coords coords?, :level :info, :id nil, :msg_ nil}))])
|
||||
(let [{rv :value, [sv] :signals} (with-sigs (tel/trace! :id1 (+ 1 2))) ] [(is (= rv 3)) (is (sm? sv {:kind :trace, :coords coords?, :level :info, :id :id1}))])
|
||||
(let [{rv :value, [sv] :signals} (with-sigs (tel/trace! {:id :id1} (+ 1 2))) ] [(is (= rv 3)) (is (sm? sv {:kind :trace, :coords coords?, :level :info, :id :id1}))])
|
||||
|
|
@ -727,7 +726,7 @@
|
|||
(is (sm? (with-sig (-> (.atWarn sl) (.log "Hello"))) {:level :warn, :ns "my.class", :kind :slf4j, :msg_ "Hello", :inst enc/inst?}) "Fluent API: warn basics")])
|
||||
|
||||
(testing "Message formatting"
|
||||
(let [msgp "x={},y={}", expected {:msg_ "x=1,y=2", :slf4j/args (fn [objs] (= (vec objs) ["1" "2"]))}]
|
||||
(let [msgp "x={},y={}", expected {:msg_ "x=1,y=2", :data {:slf4j/args ["1" "2"]}}]
|
||||
[(is (sm? (with-sig (.info sl msgp "1" "2")) expected) "Legacy API: formatted message, raw args")
|
||||
(is (sm? (with-sig (-> (.atInfo sl) (.setMessage msgp) (.addArgument "1") (.addArgument "2") (.log))) expected) "Fluent API: formatted message, raw args")]))
|
||||
|
||||
|
|
@ -738,8 +737,8 @@
|
|||
m2 (#'slf4j/est-marker! "M2")
|
||||
cm (#'slf4j/est-marker! "Compound" "M1" "M2")]
|
||||
|
||||
[(is (sm? (with-sig (.info sl cm "Hello")) {:slf4j/markers #{"Compound" "M1" "M2"}}) "Legacy API: markers")
|
||||
(is (sm? (with-sig (-> (.atInfo sl) (.addMarker m1) (.addMarker cm) (.log))) {:slf4j/markers #{"Compound" "M1" "M2"}}) "Fluent API: markers")]))
|
||||
[(is (sm? (with-sig (.info sl cm "Hello")) {:data {:slf4j/marker-names #{"Compound" "M1" "M2"}}}) "Legacy API: markers")
|
||||
(is (sm? (with-sig (-> (.atInfo sl) (.addMarker m1) (.addMarker cm) (.log))) {:data {:slf4j/marker-names #{"Compound" "M1" "M2"}}}) "Fluent API: markers")]))
|
||||
|
||||
(testing "Errors"
|
||||
[(is (sm? (with-sig (.warn sl "An error" ^Throwable ex1)) {:level :warn, :error ex1}) "Legacy API: errors")
|
||||
|
|
@ -754,15 +753,15 @@
|
|||
;;;; Timbre shim
|
||||
|
||||
(deftest _timbre-shim
|
||||
[(is (sm? (with-sig (timbre/log :warn "x1" nil "x2")) {:kind :log, :level :warn, :id timbre/shim-id, :msg_ "x1 nil x2", :timbre/vargs ["x1" nil "x2"], :ns string?}))
|
||||
(is (sm? (with-sig (timbre/info "x1" nil "x2")) {:kind :log, :level :info, :id timbre/shim-id, :msg_ "x1 nil x2", :timbre/vargs ["x1" nil "x2"], :ns string?}))
|
||||
(is (sm? (with-sig (timbre/error "x1" nil "x2")) {:kind :log, :level :error, :id timbre/shim-id, :msg_ "x1 nil x2", :timbre/vargs ["x1" nil "x2"], :ns string?}))
|
||||
[(is (sm? (with-sig (timbre/log :warn "x1" nil "x2")) {:kind :log, :level :warn, :id timbre/shim-id, :msg_ "x1 nil x2", :data {:vargs ["x1" nil "x2"]}, :ns string?}))
|
||||
(is (sm? (with-sig (timbre/info "x1" nil "x2")) {:kind :log, :level :info, :id timbre/shim-id, :msg_ "x1 nil x2", :data {:vargs ["x1" nil "x2"]}, :ns string?}))
|
||||
(is (sm? (with-sig (timbre/error "x1" nil "x2")) {:kind :log, :level :error, :id timbre/shim-id, :msg_ "x1 nil x2", :data {:vargs ["x1" nil "x2"]}, :ns string?}))
|
||||
|
||||
(is (sm? (with-sig (timbre/logf :warn "%s %s %s" "x1" nil "x2")) {:kind :log, :level :warn, :id timbre/shim-id, :msg_ "x1 nil x2", :timbre/vargs ["x1" nil "x2"], :ns string?}))
|
||||
(is (sm? (with-sig (timbre/infof "%s %s %s" "x1" nil "x2")) {:kind :log, :level :info, :id timbre/shim-id, :msg_ "x1 nil x2", :timbre/vargs ["x1" nil "x2"], :ns string?}))
|
||||
(is (sm? (with-sig (timbre/errorf "%s %s %s" "x1" nil "x2")) {:kind :log, :level :error, :id timbre/shim-id, :msg_ "x1 nil x2", :timbre/vargs ["x1" nil "x2"], :ns string?}))
|
||||
(is (sm? (with-sig (timbre/logf :warn "%s %s %s" "x1" nil "x2")) {:kind :log, :level :warn, :id timbre/shim-id, :msg_ "x1 nil x2", :data {:vargs ["x1" nil "x2"]}, :ns string?}))
|
||||
(is (sm? (with-sig (timbre/infof "%s %s %s" "x1" nil "x2")) {:kind :log, :level :info, :id timbre/shim-id, :msg_ "x1 nil x2", :data {:vargs ["x1" nil "x2"]}, :ns string?}))
|
||||
(is (sm? (with-sig (timbre/errorf "%s %s %s" "x1" nil "x2")) {:kind :log, :level :error, :id timbre/shim-id, :msg_ "x1 nil x2", :data {:vargs ["x1" nil "x2"]}, :ns string?}))
|
||||
|
||||
(is (sm? (with-sig (timbre/info ex1 "x1" "x2")) {:kind :log, :level :info, :error ex1, :msg_ "x1 x2", :timbre/vargs ["x1" "x2"]}) "First-arg error")
|
||||
(is (sm? (with-sig (timbre/info ex1 "x1" "x2")) {:kind :log, :level :info, :error ex1, :msg_ "x1 x2", :data {:vargs ["x1" "x2"]}}) "First-arg error")
|
||||
|
||||
(is (sm? (with-sig (timbre/spy :info "my-name" (+ 1 2))) {:kind :spy, :level :info, :id timbre/shim-id, :msg_ "my-name => 3", :ns string?}))
|
||||
(is (sm? (tel/with-min-level :debug (with-sig (timbre/spy (+ 1 2)))) {:kind :spy, :level :debug, :id timbre/shim-id, :msg_ "(+ 1 2) => 3", :ns string?}))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
(defproject com.taoensso/telemere-slf4j "1.2.1"
|
||||
(defproject com.taoensso/telemere-slf4j "1.1.0"
|
||||
:author "Peter Taoussanis <https://www.taoensso.com>"
|
||||
:description "Telemere backend/provider for SLF4J API v2"
|
||||
:url "https://www.taoensso.com/telemere"
|
||||
|
|
@ -16,9 +16,9 @@
|
|||
:profiles
|
||||
{:provided
|
||||
{:dependencies
|
||||
[[org.clojure/clojure "1.12.3"]
|
||||
[[org.clojure/clojure "1.12.1"]
|
||||
[org.slf4j/slf4j-api "2.0.17"]
|
||||
[com.taoensso/telemere "1.2.1"]]}
|
||||
[com.taoensso/telemere "1.1.0"]]}
|
||||
|
||||
:dev
|
||||
{:plugins
|
||||
|
|
|
|||
|
|
@ -63,13 +63,13 @@
|
|||
|
||||
(comment [(est-marker! "a1" "a2") (get-marker "a1") (= (get-marker "a1") (get-marker "a1"))])
|
||||
|
||||
(def ^:private get-marker-names
|
||||
(def ^:private marker-names
|
||||
"Returns #{<MarkerName>}. Cached => assumes markers NOT modified after creation."
|
||||
;; We use `BasicMarkerFactory` so:
|
||||
;; 1. Our markers are just labels (no other content besides their name).
|
||||
;; 2. Markers with the same name are identical (enabling caching).
|
||||
(enc/fmemoize
|
||||
(fn get-marker-names [marker-or-markers]
|
||||
(fn marker-names [marker-or-markers]
|
||||
(if (instance? org.slf4j.Marker marker-or-markers)
|
||||
|
||||
;; Single marker
|
||||
|
|
@ -82,12 +82,12 @@
|
|||
(fn [acc ^org.slf4j.Marker in]
|
||||
(if-not (.hasReferences in)
|
||||
(conj acc (.getName in))
|
||||
(into acc (get-marker-names in))))
|
||||
(into acc (marker-names in))))
|
||||
acc (.iterator m))))
|
||||
|
||||
;; Vector of markers
|
||||
(reduce
|
||||
(fn [acc in] (into acc (get-marker-names in)))
|
||||
(fn [acc in] (into acc (marker-names in)))
|
||||
#{} (truss/have vector? marker-or-markers))))))
|
||||
|
||||
(comment
|
||||
|
|
@ -97,9 +97,9 @@
|
|||
ms [m1 m2]]
|
||||
|
||||
(enc/qb 1e6 ; [45.52 47.48 44.85]
|
||||
(get-marker-names m1)
|
||||
(get-marker-names cm)
|
||||
(get-marker-names ms))))
|
||||
(marker-names m1)
|
||||
(marker-names cm)
|
||||
(marker-names ms))))
|
||||
|
||||
;;;; Interop fns (called by `TelemereLogger`)
|
||||
|
||||
|
|
@ -132,10 +132,11 @@
|
|||
(org.slf4j.helpers.MessageFormatter/basicArrayFormat
|
||||
msg-pattern args))
|
||||
|
||||
:slf4j/args args ; Object[]
|
||||
:slf4j/markers marker-names ; Usu. used for routing, filtering, xfns, etc.
|
||||
:data (when kvs {:slf4j/kvs kvs})})
|
||||
|
||||
:data
|
||||
(enc/assoc-some nil
|
||||
:slf4j/marker-names marker-names
|
||||
:slf4j/args (when args (vec args))
|
||||
:slf4j/kvs kvs)})
|
||||
nil)
|
||||
|
||||
(defn- log!
|
||||
|
|
@ -148,7 +149,7 @@
|
|||
error (.getThrowable event)
|
||||
msg-pattern (.getMessage event)
|
||||
args (when-let [args (.getArgumentArray event)] args)
|
||||
marker-names (when-let [markers (.getMarkers event)] (get-marker-names (vec markers)))
|
||||
markers (when-let [markers (.getMarkers event)] (marker-names (vec markers)))
|
||||
kvs (when-let [kvps (.getKeyValuePairs event)]
|
||||
(reduce
|
||||
(fn [acc ^org.slf4j.event.KeyValuePair kvp]
|
||||
|
|
@ -156,11 +157,11 @@
|
|||
nil kvps))]
|
||||
|
||||
(when-debug (println [:slf4j/fluent-log-call (sig-level level) logger-name]))
|
||||
(normalized-log! logger-name level inst error msg-pattern args marker-names kvs)))
|
||||
(normalized-log! logger-name level inst error msg-pattern args markers kvs)))
|
||||
|
||||
;; Legacy API calls
|
||||
([logger-name ^org.slf4j.event.Level level error msg-pattern args marker]
|
||||
(let [marker-names (when marker (get-marker-names marker))]
|
||||
(let [marker-names (when marker (marker-names marker))]
|
||||
(when-debug (println [:slf4j/legacy-log-call (sig-level level) logger-name]))
|
||||
(normalized-log! logger-name level (enc/now-inst*) error msg-pattern args marker-names nil))))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue