Liking cljdoc? Tell your friends :D

Ring middleware implementing the W3C Trace Context Standard

Middleware

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 the wrapped handler under the :traceparent key.

request =>
{:request-method :get
 # ...
 :traceparent {:version "00",
               :trace-id "74e744b8a6cb016a0ebf84d7d7932512",
               :parent-id "23fc93418d1e37bd",
               :trace-flags "00"}}

Headers

The standard defines two headers; traceparent and tracestate.

traceparent

The 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".

tracestate

TODO: document further

References

https://newrelic.com/blog/nerdlog/w3c-trace-context-distributed-tracing-standard

https://www.w3.org/TR/trace-context/

Changes

0.0.5

  • Add new-context alias for new-span and fix implementation when nil is passed.

0.0.4

  • Add *trace-context* dynamic var, and related functions.

0.0.3

  • Set traceparent header also on response in middleware
  • Set trace-context on request and response map
  • Add new-span
  • Renaming for clarity: use trace-context for parsed objects and traceparent for raw string.

Can you improve this documentation?Edit on sourcehut

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close