Liking cljdoc? Tell your friends :D

steffan-westcott.clj-otel.context

Functions for working with io.opentelemetry.context.Context objects.

Functions for working with `io.opentelemetry.context.Context` objects.
raw docstring

->headersclj

(->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:

keydescription
:contextContext to propagate (default: bound or current context).
:text-map-propagatorPropagator 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).
sourceraw docstring

AsContextKeycljprotocol

context-keyclj

(context-key k)

Coerces k to a ContextKey.

Coerces k to a `ContextKey`.
source

assoc-valueclj

(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.
sourceraw docstring

bind-context!cljmacro

(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.
sourceraw docstring

bound-context-interceptorclj

(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`).
sourceraw docstring

close-scope!clj

(close-scope! scope)

Closes the given scope.

Closes the given scope.
sourceraw docstring

currentclj

(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.
sourceraw docstring

current-context-interceptorclj

(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`.
sourceraw docstring

dynclj

(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.
sourceraw docstring

get-valueclj

(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.
sourceraw docstring

headers->merged-contextclj

(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:

keydescription
:contextContext to merge with (default: bound or current context).
:text-map-propagatorPropagator 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).
sourceraw docstring

rootclj

(root)

Returns the root context that all other contexts are derived from.

Returns the root context that all other contexts are derived from.
sourceraw docstring

set-current!clj

(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.
sourceraw docstring

with-bound-context!cljmacro

(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.
sourceraw docstring

with-context!cljmacro

(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.
sourceraw docstring

with-value!cljmacro

(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.
sourceraw docstring

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

× close