Skip to content

Commit 29b402a

Browse files
committed
Document OpenTelemetry configuration
1 parent 1814839 commit 29b402a

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
;; pass a context map to add structured data to the message
3838
(log/info "hi!" {:foo "bar" :baz "qux"})
3939

40-
;; context can be set
40+
;; context can be set
4141
(log/with-context {:action "vibe-check"}
4242
(log/debug "checking the vibes")
4343
(let [are-you-ok? (do-the-vibe-check)]
@@ -70,7 +70,7 @@ Second part of ensuring that right things are logged and we keep a good performa
7070

7171
### How does it work?
7272

73-
Mokujin wraps `clojure.tools.logging` and injects SLF4J's MDC into logging events, if provided.
73+
Mokujin wraps `clojure.tools.logging` and injects SLF4J's MDC into logging events, if provided.
7474
Keep in mind that `infof` (and friends) variants are present, but do not support passing the MDC (more on that later).
7575

7676

@@ -138,7 +138,7 @@ Second difference is that only 1- and 2-arity (or in case of `log/error` 3-arity
138138
(log/info "hello" "there" "world")
139139
```
140140

141-
To help with migration and good log hygine Mokujin ships with custom hooks for `clj-kondo` and
141+
To help with migration and good log hygine Mokujin ships with custom hooks for `clj-kondo` and
142142
report warnings in case of suspicious or incompatible call styles are detected.
143143

144144

@@ -271,6 +271,32 @@ This way we can delegate things like redacting MDC or async appenders to Logback
271271

272272
Check `:mokujin.logback/json-async` configuration preset for a good example of how to set up async appenders with MDC support.
273273

274+
275+
#### Open Telemetry
276+
277+
278+
Open Telemetry supports automatic instrumentation of logging frameworks including Logback. To enable it, you need to:
279+
280+
- start your application with the Open Telemetry Java agent
281+
- ensure that following environement variables are set:
282+
283+
```
284+
export OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_LOGGER_CONTEXT_ATTRIBUTES=true
285+
export OTEL_INSTRUMENTATION_LOGBACK_APPENDER_EXPERIMENTAL_CAPTURE_MDC_ATTRIBUTES=*
286+
```
287+
288+
alternatively, you can set these properties via JVM options:
289+
290+
```
291+
-Dotel.instrumentation.logback.appender.experimental.capture.logger.context.attributes=true
292+
-Dotel.instrumentation.logback.appender.experimental.capture.mdc.attributes=*
293+
```
294+
295+
296+
From there, Open Telemetry will automatically capture MDC attributes and attach them to spans, inject trace IDs etc.
297+
298+
299+
274300
## TODO
275301

276302
- [x] Maven release

0 commit comments

Comments
 (0)