This package defines the
nl.jomco.ring-trace-context/wrap-trace-context middleware function.
This parses the traceparent header if present or generates new
traceparent data and sets it on the request for, and the response of
the wrapped handler under the :trace-context key.
request =>
{:request-method :get
 # ...
 :trace-context {:version "00",
                 :trace-id "74e744b8a6cb016a0ebf84d7d7932512",
                 :parent-id "23fc93418d1e37bd",
                 :trace-flags "00"}}
nl.jomco.ring-trace-context/*trace-context* holds the current
trace context while the wrapped handler is called. You can also use
(with-context (new-context) ...) to create new (sub) contexts.
If you want to pass trace context along to other services you can use
wrap-new-trace-context to wrap around your HTTP client function.
something like
(def http-client
	(-> clj-http.client/request
		(wrap-new-trace-context)))
;; automatically spawns a new trace context based on
;; the current context on every request
(http-client {:method :get
              :url    "http://example.com"})
With clj-http you can also use its with-additional-middleware
macro and related functionality.
The standard defines two headers; traceparent and
tracestate.
traceparentThe traceparent header contains 4 fields, version, trace-id,
parent-id and flags. The only currenly defined versions are "00"
(hexadecimal), and the "invalid version" "ff".
tracestateTODO: document further
https://newrelic.com/blog/nerdlog/w3c-trace-context-distributed-tracing-standard
https://www.w3.org/TR/trace-context/
new-context alias for new-span and fix implementation when
nil is passed.*trace-context* dynamic var and related functions.traceparent header also on response in middlewaretrace-context on request and response mapnew-spantrace-context for parsed objects and
traceparent for raw string.Can you improve this documentation?Edit on sourcehut
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs | 
| ← | Move to previous article | 
| → | Move to next article | 
| Ctrl+/ | Jump to the search field |