Functions for working with io.opentelemetry.context.Context
objects.
Functions for working with `io.opentelemetry.context.Context` objects.
(->headers)
(->headers {:keys [context text-map-propagator]
:or {context (current)
text-map-propagator (otel/get-text-map-propagator)}})
Returns a map to merge into the headers of an HTTP request for the purpose of context propagation i.e. transfer context to a remote server. May take an optional map argument as follows:
key | description |
---|---|
:context | Context to propagate (default: current context). |
:text-map-propagator | Propagator used to create headers map entries (default: propagator set in global OpenTelemetry instance). |
Returns a map to merge into the headers of an HTTP request for the purpose of context propagation i.e. transfer context to a remote server. May take an optional map argument as follows: | key | description | |----------------------|-------------| |`:context` | Context to propagate (default: current context). |`:text-map-propagator`| Propagator used to create headers map entries (default: propagator set in global `OpenTelemetry` instance).
(context-key k)
Coerces k to a ContextKey
.
Coerces k to a `ContextKey`.
(assoc-value context implicit-context-keyed)
(assoc-value context key value)
Associates a key-value with a context
, returning a new Context
that
includes the key-value. Does not use nor affect the current context. Takes
key
and value
, or an ImplicitContextKeyed
instance which is a value
that uses a predetermined key.
Associates a key-value with a `context`, returning a new `Context` that includes the key-value. Does not use nor affect the current context. Takes `key` and `value`, or an `ImplicitContextKeyed` instance which is a value that uses a predetermined key.
(close-scope! scope)
Closes the given scope.
Closes the given scope.
(current)
Returns the current context, a thread local Context
object. If no such
context exists, the root context is returned instead.
Returns the current context, a thread local `Context` object. If no such context exists, the root context is returned instead.
(current-context-interceptor context-key scope-key)
Returns a Pedestal interceptor that will on entry set the current context to
the value that has key context-key
in the interceptor context map. The
original value of current context is restored on evaluation on interceptor
exit (either leave
or error
). The Scope
of the set context is stored
in the interceptor context map with key scope-key
.
Returns a Pedestal interceptor that will on entry set the current context to the value that has key `context-key` in the interceptor context map. The original value of current context is restored on evaluation on interceptor exit (either `leave` or `error`). The `Scope` of the set context is stored in the interceptor context map with key `scope-key`.
(get-value context key)
Returns the value stored in the context for the given context key.
Returns the value stored in the context for the given context key.
(headers->merged-context headers)
(headers->merged-context
headers
{:keys [context text-map-propagator]
:or {context (current) text-map-propagator (otel/get-text-map-propagator)}})
Returns a context formed by extracting a propagated context from a map
headers
and merging with another context i.e. accept context transfer from
a remote server. May take an option map as follows:
key | description |
---|---|
:context | Context to merge with (default: current context). |
:text-map-propagator | Propagator used to extract data from the headers map (default: propagator set in global OpenTelemetry instance). |
Returns a context formed by extracting a propagated context from a map `headers` and merging with another context i.e. accept context transfer from a remote server. May take an option map as follows: | key | description | |----------------------|-------------| |`:context` | Context to merge with (default: current context). |`:text-map-propagator`| Propagator used to extract data from the headers map (default: propagator set in global `OpenTelemetry` instance).
(root)
Returns the root context that all other contexts are derived from.
Returns the root context that all other contexts are derived from.
(set-current! context)
Sets the current context. The returned Scope
must be closed to prevent
broken traces and memory leaks. with-context!
and with-value!
can
be used instead of this function to ensure the scope is closed when leaving a
lexical boundary i.e. a body of forms.
Sets the current context. The returned `Scope` must be closed to prevent broken traces and memory leaks. [[with-context!]] and [[with-value!]] can be used instead of this function to ensure the scope is closed when leaving a lexical boundary i.e. a body of forms.
(with-context! context & body)
Sets the current context to be the provided context
, then evaluates
body
. The original current context is restored after body evaluation
completes.
Sets the current context to be the provided `context`, then evaluates `body`. The original current context is restored after body evaluation completes.
(with-value! implicit-context-keyed & body)
Make a new current context by associating an ImplicitContextKeyed
instance
implicit-context-keyed
then evaluate body
. The original current context
is restored after body evaluation completes.
Make a new current context by associating an `ImplicitContextKeyed` instance `implicit-context-keyed` then evaluate `body`. The original current context is restored after body evaluation completes.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close