Orkestra.Telemetry (orkestra v0.2.0)

Copy Markdown View Source

OpenTelemetry tracing and structured logging helpers for Orkestra.

Provides span creation, attribute extraction, and trace context propagation for the CQRS pipeline.

Summary

Functions

Clears Orkestra-specific Logger metadata.

Creates span attributes from a command envelope.

Creates span attributes for an Orkestra.ES.Repository operation.

Creates span attributes for an ES storage operation (single-doc or bulk).

Creates span attributes from an event envelope.

Extracts OTel trace context from AMQP headers into the current process.

Injects the current OTel trace context into AMQP-compatible headers. Returns a list of {key, :longstr, value} tuples.

Creates span attributes from Orkestra metadata.

Converts Metadata to a Logger-compatible keyword list.

Creates span attributes for a projector event-processing span.

Sets Logger metadata from Orkestra metadata for the current process. Also injects trace_id and span_id from the current OTel context so that logs can be correlated with traces in SigNoz. Call this at the start of handler execution.

Wraps a function in a named span with Orkestra attributes. Automatically sets span status to error on {:error, _} returns.

Functions

clear_logger_metadata()

Clears Orkestra-specific Logger metadata.

command_attrs(command_envelope)

Creates span attributes from a command envelope.

es_repo_span_attrs(schema, index, culture)

@spec es_repo_span_attrs(module(), String.t(), atom() | nil) :: map()

Creates span attributes for an Orkestra.ES.Repository operation.

Used by the generated repository functions (get/2, save/2, count/2, …) to describe the targeted index and resolved culture. Never include cluster credentials or adapter options here (convention T-08-02).

es_span_attrs(projector_name, index, engine, doc_count \\ nil)

@spec es_span_attrs(String.t(), String.t(), atom(), non_neg_integer() | nil) :: map()

Creates span attributes for an ES storage operation (single-doc or bulk).

event_attrs(event_envelope)

Creates span attributes from an event envelope.

extract_context_from_headers(headers)

Extracts OTel trace context from AMQP headers into the current process.

inject_context_to_headers()

Injects the current OTel trace context into AMQP-compatible headers. Returns a list of {key, :longstr, value} tuples.

metadata_attrs(meta)

Creates span attributes from Orkestra metadata.

metadata_to_logger(meta)

Converts Metadata to a Logger-compatible keyword list.

projector_span_attrs(projector_name, event, position)

@spec projector_span_attrs(String.t(), map(), non_neg_integer()) :: map()

Creates span attributes for a projector event-processing span.

set_logger_metadata(meta)

Sets Logger metadata from Orkestra metadata for the current process. Also injects trace_id and span_id from the current OTel context so that logs can be correlated with traces in SigNoz. Call this at the start of handler execution.

with_span(name, attrs, fun)

Wraps a function in a named span with Orkestra attributes. Automatically sets span status to error on {:error, _} returns.