View Source otel_ctx (opentelemetry_api v1.3.0)

Ctx is responsible for propagating values within a process that are associated with a particular Trace or set of Baggage. OpenTelemetry.Tracer and OpenTelemetry.Baggage handle updating the Context.

Functions in this module include variants that explicitly take a Ctx argument and variants that implicitly use the current context, which is the context stored in the process dictionary.

Link to this section Summary

Types

A context key.
t/0
A context map.
An opaque token that represents a context.
A context value.

Functions

Attaches the given context to the current process.

Removes all key-value pairs from the current context.

Removes all key-value pairs from the given context.

Detaches the given context from the current process.
Returns the current context.
Gets a value from the current context under the given key.
Gets a value from the current context under the given key, or returns the default value if the key is not present in the current context.
Gets a value from the given context under the given key, or returns the default value if the key is not present in the given context or if Ctx is undefined.
Creates a new context.
Removes the value under the given key from the current context.

Removes the value under the given key from the given context.

Sets a value in the current context under the given key.

Sets a value in the given context under the given key.

Attaches a context and runs a function, detaching the context at the end.

Link to this section Types

-type key() :: term().
A context key.
-type t() :: map() | undefined.
A context map.
-opaque token()
An opaque token that represents a context.
-type value() :: term().
A context value.

Link to this section Functions

-spec attach(t()) -> token().

Attaches the given context to the current process.

Essentially, this sets Ctx as the current context .
-spec clear() -> ok.
Removes all key-value pairs from the current context.
-spec clear(t()) -> t().

Removes all key-value pairs from the given context.

Returns an empty context.
-spec detach(token()) -> t() | undefined.
Detaches the given context from the current process.
-spec get_current() -> map().
Returns the current context.
-spec get_value(term()) -> eqwalizer:dynamic().
Gets a value from the current context under the given key.
-spec get_value(term(), term()) -> eqwalizer:dynamic().
Gets a value from the current context under the given key, or returns the default value if the key is not present in the current context.
Link to this function

get_value(Ctx, Key, Default)

View Source
-spec get_value(t(), term(), term()) -> eqwalizer:dynamic().
Gets a value from the given context under the given key, or returns the default value if the key is not present in the given context or if Ctx is undefined.
-spec new() -> t().
Creates a new context.
-spec remove(term()) -> ok.
Removes the value under the given key from the current context.
-spec remove(t(), term()) -> t().

Removes the value under the given key from the given context.

Returns the updated context.
-spec set_value(term(), term()) -> ok.
Sets a value in the current context under the given key.
Link to this function

set_value(Ctx, Key, Value)

View Source
-spec set_value(t(), term(), term()) -> t().

Sets a value in the given context under the given key.

Returns the updated context.
-spec with_ctx(t(), fun(() -> term())) -> {term(), t()}.

Attaches a context and runs a function, detaching the context at the end.

Returns the detached context.