:telemetry events emitted by CodexWrapper.
The synchronous command and session events use :telemetry.span/3.
Streaming events follow the same start/stop/exception convention while
keeping the span open for the lifetime of lazy enumeration.
Events
[:codex_wrapper, :exec, :start | :stop | :exception]— emitted aroundCodexWrapper.Exec.execute/2andCodexWrapper.ExecResume.execute/2.[:codex_wrapper, :stream, :start | :stop | :exception]— emitted while consuming streams returned byCodexWrapper.Exec.stream/2,CodexWrapper.ExecResume.stream/2, andCodexWrapper.Review.stream/2. Start is emitted on first reduction; stop is emitted on producer exhaustion or an early consumer halt.[:codex_wrapper, :review, :start | :stop | :exception]— emitted aroundCodexWrapper.Review.execute/2.[:codex_wrapper, :session, :turn, :start | :stop | :exception]— emitted around each synchronousCodexWrapper.Session.send/3turn.
execute_json/2 uses the corresponding execute/2 path and therefore
emits the same exec or review event rather than a second JSON-specific
event.
Measurements
:start—%{monotonic_time: integer(), system_time: integer()}:stop—%{monotonic_time: integer(), duration: integer()}:exception—%{monotonic_time: integer(), duration: integer()}
Metadata
Every event includes:
:command— one of:exec,:exec_resume,:review,:session_exec, or:session_resume:session_id— the session identifier when known:sandbox_mode— the configured sandbox mode when present:approval_policy— the configured approval policy when present
Synchronous stop events additionally include :exit_code when the
wrapped call returns a %CodexWrapper.Result{}. Stream events do not
include an exit code because the lazy Runner contract does not expose
one. Exception metadata follows the standard span shape with :kind,
:reason, and :stacktrace.
Example
:telemetry.attach_many(
"codex-wrapper-logger",
[
[:codex_wrapper, :exec, :stop],
[:codex_wrapper, :stream, :stop],
[:codex_wrapper, :review, :stop],
[:codex_wrapper, :session, :turn, :stop]
],
fn event, measurements, metadata, _config ->
require Logger
Logger.info(
"#{inspect(event)} duration=#{measurements.duration} " <>
"metadata=#{inspect(metadata)}"
)
end,
nil
)
Summary
Functions
Build metadata for an Exec or ExecResume command.
Build metadata for a Review command.
Build metadata for a session turn.
Run a synchronous function inside a telemetry span.
Instrument the full lifecycle of a lazy enumerable.
Types
Functions
Build metadata for an Exec or ExecResume command.
Build metadata for a Review command.
Build metadata for a session turn.
@spec span(event_name(), metadata(), (-> result)) :: result when result: var
Run a synchronous function inside a telemetry span.
The function's return value is preserved. When it contains a
%CodexWrapper.Result{}, its exit code is added to stop metadata.
@spec span_stream(event_name(), metadata(), (-> Enumerable.t())) :: Enumerable.t()
Instrument the full lifecycle of a lazy enumerable.
No event is emitted and stream_fun is not called until the returned
enumerable is first reduced. The stop event is emitted after the producer
finishes or the consumer halts it. Producer and consumer exceptions emit
an exception event and are re-raised without a stop event.