The trace-context in the current scope.
This will be set by wrap-trace-context
automatically. Use
with-context
otherwise.
The trace-context in the current scope. This will be set by `wrap-trace-context` automatically. Use `with-context` otherwise.
(generate-traceparent trace-context)
Returns a traceparent header value from the given trace-context
.
Returns a traceparent header value from the given `trace-context`.
(get-context request-or-response)
Get the trace-context from the given ring request-or-response
.
Will return nil
if no traceparent header is present.
Get the trace-context from the given ring `request-or-response`. Will return `nil` if no traceparent header is present.
(new-context)
(new-context base-trace-context)
Returns a new context off the given base-trace-context
.
The returned trace-context has the same properties as the given
base-trace-context
but with a random :parent-id
.
If base-trace-context
is nil
, returns a random context.
If no argument is passed, uses *trace-context*
as the base.
Returns a new context off the given `base-trace-context`. The returned trace-context has the same properties as the given `base-trace-context` but with a random `:parent-id`. If `base-trace-context` is `nil`, returns a random context. If no argument is passed, uses `*trace-context*` as the base.
(new-span)
(new-span trace-context)
Same as new-context
.
Same as `new-context`.
(parse-traceparent traceparent)
Parse traceparent
string and return a trace-context map.
This will fully parse version "00" traceparent values.
trace-context map contains :version, :trace-id, :parent-id and :trace-flags (a set of keywords).
The only currently supported trace-flag is :sampled.
Returns nil
if traceparent
is not a valid traceparent value.
See also https://www.w3.org/TR/trace-context
Parse `traceparent` string and return a trace-context map. This will fully parse version "00" traceparent values. trace-context map contains :version, :trace-id, :parent-id and :trace-flags (a set of keywords). The only currently supported trace-flag is :sampled. Returns `nil` if `traceparent` is not a valid traceparent value. See also https://www.w3.org/TR/trace-context
(random-context)
Create new random trace-context.
:trace-id
and :parent-id
are random. :version
is always "00"
and :trace-flags
is empty.
Create new random trace-context. `:trace-id` and `:parent-id` are random. `:version` is always "00" and `:trace-flags` is empty.
(set-context request-or-response trace-context)
Set the traceparent header for trace-context
on request-or-response
.
Set the traceparent header for `trace-context` on `request-or-response`.
(with-context trace-context & body)
Bind *trace-context*
to trace-context
and evaluate body
.
Bind `*trace-context*` to `trace-context` and evaluate `body`.
(wrap-new-trace-context handler)
Add new trace context to outgoing request
.
Middleware for clj-http.client
type HTTP clients. Wraps a
handler
and returns a handler that will start a new trace
context, based off of the current trace-context, on every call.
Adds the :trace-context
key and a traceparent
header to
request
. See also with-context
and new-context
.
See wrap-trace-context
for Ring middleware.
Add new trace context to outgoing `request`. Middleware for `clj-http.client` type HTTP clients. Wraps a `handler` and returns a handler that will start a new trace context, based off of the current trace-context, on every call. Adds the `:trace-context` key and a `traceparent` header to `request`. See also `with-context` and `new-context`. See `wrap-trace-context` for Ring middleware.
(wrap-trace-context handler)
Ring middleware for Trace Context.
Implements the W3C Trace Context protocol. When a request has a
traceparent
header, this gets parsed into a trace-context
.
The trace-context
is set on the request passed to handler
, and
also set on the response returned by handler
using the
:trace-context
key.
If no traceparent
is set, or traceparent
is not valid, a new
random trace-context
is created.
Sets the response traceparent
header to the trace-context used.
During call to handler
, *trace-context*
is also bound to
trace-context
. The value of *trace-context*
in the outer scope
is ignored -- the incoming HTTP request either provides a trace
context, or a fresh context is created.
See wrap-new-trace-context
for HTTP client middleware.
See also https://www.w3.org/TR/trace-context/
Ring middleware for Trace Context. Implements the W3C Trace Context protocol. When a request has a `traceparent` header, this gets parsed into a `trace-context`. The `trace-context` is set on the request passed to `handler`, and also set on the response returned by `handler` using the `:trace-context` key. If no `traceparent` is set, or `traceparent` is not valid, a new random `trace-context` is created. Sets the response `traceparent` header to the trace-context used. During call to `handler`, `*trace-context*` is also bound to `trace-context`. The value of `*trace-context*` in the outer scope is ignored -- the incoming HTTP request either provides a trace context, or a fresh context is created. See `wrap-new-trace-context` for HTTP client middleware. See also https://www.w3.org/TR/trace-context/
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close