instrument_propagation (instrument v0.6.1)

View Source

Context propagation helpers for cross-process communication.

This module provides helpers for propagating context across process boundaries and encoding/decoding W3C TraceContext format.

Summary

Functions

Makes a gen_server call with the current context propagated. The server must be aware of context propagation to use this.

Makes a gen_server call with the current context propagated and timeout.

Makes a gen_server cast with the current context propagated.

Extracts trace context from a carrier (map). Uses all registered propagators.

Extracts trace context from a carrier into an existing context. Uses all registered propagators.

Extracts context from HTTP headers.

Injects the current trace context into a carrier (map). Uses all registered propagators.

Injects trace context into a carrier (map). Uses all registered propagators.

Injects context into HTTP headers format.

Spawns a process with the current context propagated.

Spawns a process with args and the current context propagated.

Spawns a linked process with the current context propagated.

Spawns a linked process with args and the current context propagated.

Spawns a monitored process with the current context propagated.

Spawns a process with options and the current context propagated.

Functions

call_with_context(ServerRef, Request)

-spec call_with_context(term(), term()) -> term().

Makes a gen_server call with the current context propagated. The server must be aware of context propagation to use this.

call_with_context(ServerRef, Request, Timeout)

-spec call_with_context(term(), term(), timeout()) -> term().

Makes a gen_server call with the current context propagated and timeout.

cast_with_context(ServerRef, Msg)

-spec cast_with_context(term(), term()) -> ok.

Makes a gen_server cast with the current context propagated.

extract(Carrier)

-spec extract(map()) -> instrument_context:context().

Extracts trace context from a carrier (map). Uses all registered propagators.

extract(Carrier, Ctx)

Extracts trace context from a carrier into an existing context. Uses all registered propagators.

extract_headers(Headers)

-spec extract_headers([{binary() | string(), binary() | string()}]) -> instrument_context:context().

Extracts context from HTTP headers.

inject(Carrier)

-spec inject(map()) -> map().

Injects the current trace context into a carrier (map). Uses all registered propagators.

inject(Ctx, Carrier)

-spec inject(instrument_context:context(), map()) -> map().

Injects trace context into a carrier (map). Uses all registered propagators.

inject_headers(Ctx)

-spec inject_headers(instrument_context:context()) -> [{binary(), binary()}].

Injects context into HTTP headers format.

spawn(Fun)

-spec spawn(fun(() -> term())) -> pid().

Spawns a process with the current context propagated.

spawn(Fun, Args)

-spec spawn(fun((...) -> term()), list()) -> pid().

Spawns a process with args and the current context propagated.

spawn_link(Fun)

-spec spawn_link(fun(() -> term())) -> pid().

Spawns a linked process with the current context propagated.

spawn_link(Fun, Args)

-spec spawn_link(fun((...) -> term()), list()) -> pid().

Spawns a linked process with args and the current context propagated.

spawn_monitor(Fun)

-spec spawn_monitor(fun(() -> term())) -> {pid(), reference()}.

Spawns a monitored process with the current context propagated.

spawn_opt(Fun, Opts)

-spec spawn_opt(fun(() -> term()), [term()]) -> pid() | {pid(), reference()}.

Spawns a process with options and the current context propagated.