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 (dyn)
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: bound or current context). |
:text-map-propagator | Propagator used to create headers map entries (default: propagator set in default or 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: bound or current context). |`:text-map-propagator`| Propagator used to create headers map entries (default: propagator set in default or 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.
(bind-context! context & body)
Sets the bound context to be the provided context
, then evaluates body
.
The original bound context is restored after body evaluation completes.
Sets the bound context to be the provided `context`, then evaluates `body`. The original bound context is restored after body evaluation completes.
(bound-context-interceptor context-key)
Returns a Pedestal interceptor that will set the bound context to the value
that has key context-key
in the interceptor context map. The bound context
(a dynamic var) is set for subsequent interceptors in the chain; the bound
context is unset when this interceptor exits (either leave
or error
).
Returns a Pedestal interceptor that will set the bound context to the value that has key `context-key` in the interceptor context map. The bound context (a dynamic var) is set for subsequent interceptors in the chain; the bound context is unset when this interceptor exits (either `leave` or `error`).
(close-scope! scope)
Closes the given scope.
Closes the given scope.
(current)
Returns the current context, which is stored in a thread local Context
object. If no such context exists, the root context is returned instead.
Returns the current context, which is stored in 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`.
(dyn)
Returns the bound context, which is stored in a Clojure dynamic var. If no context is bound, the current context is returned instead.
Returns the bound context, which is stored in a Clojure dynamic var. If no context is bound, the current context is returned instead.
(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 (dyn) 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: bound or current context). |
:text-map-propagator | Propagator used to extract data from the headers map (default: propagator set in default or 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: bound or current context). |`:text-map-propagator`| Propagator used to extract data from the headers map (default: propagator set in default or 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-bound-context! & body)
Sets the current context to the bound context, then evaluates body
. The
original current context is restored after body evaluation completes.
Sets the current context to the bound context, then evaluates `body`. The original current context is restored after body evaluation completes.
(with-context! context & body)
Sets the current and bound context to be the provided context
, then
evaluates body
. The original contexts are restored after body evaluation
completes.
Sets the current and bound context to be the provided `context`, then evaluates `body`. The original contexts are restored after body evaluation completes.
(with-value! implicit-context-keyed & body)
Associates an ImplicitContextKeyed
instance implicit-context-keyed
with
the bound or current context, sets this as the current and bound context,
then evaluates body
. The original contexts are restored after body
evaluation completes.
Associates an `ImplicitContextKeyed` instance `implicit-context-keyed` with the bound or current context, sets this as the current and bound context, then evaluates `body`. The original contexts are restored after body evaluation completes.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close