Arcadic.Telemetry (Arcadic v4.0.1)

Copy Markdown View Source

Defines the telemetry spans and events emitted by Arcadic. The wrapper checks metadata keys against allowed_meta_keys/0. Arcadic does not include statement text, parameters, row values, or database names.

Spans

All spans use [:arcadic, operation, phase], with phases :start, :stop, and :exception. Span timing and exception fields come from :telemetry.span/3.

OperationCalls
:queryStatement reads, including bookmarked reads.
:commandWrites, bookmarked writes, and asynchronous submission.
:explainPlan inspection and profiling.
:transactionManaged transactions.
:adminServer, security, and backup operations that use the admin wrapper.
:bulk, :ingest, :recordBatch ingest, document ingest, and record operations.
:timeseriesTime-series wire operations.

Query, command, and plan start metadata includes language and mode. Synchronous writes and profiling also report :in_transaction?. Asynchronous submissions use :async? and have no row count. A successful synchronous statement stop adds HTTP status, reason, and row count. A failed statement stop adds the reason.

Transaction spans include :isolation. Admin spans include :operation and a stop reason. Exception events include the metadata from the start plus the telemetry library's kind, reason, and stacktrace.

Events

EventMeasurements and metadata
[:arcadic, :query_stream, :start]HTTP and Bolt streams. Read mode metadata.
[:arcadic, :query_stream, :stop]HTTP and Bolt streams. Row count measurement and an :ok or :halted reason.
[:arcadic, :transaction, :retry]Attempt measurement and retry reason.
[:arcadic, :vector, :sparse_index_preexisting]Count of pre-existing rows reported by the server.
[:arcadic, :changes, :dropped]Count of dropped events and :changes operation metadata.

See Arcadic.Changes for connection lifecycle events.

Summary

Functions

The permitted span metadata keys.

Emit a manual :telemetry.execute/3 event with allowlist-validated metadata, for lazy operations (streaming) whose lifetime does not fit span/3's synchronous callback. Off-allowlist metadata keys raise (no statement/params/values/db name).

Runs fun inside :telemetry.span([:arcadic, op], …). fun returns {result, stop_meta}; every start/stop metadata key MUST be in the allowlist or an ArgumentError is raised.

Functions

allowed_meta_keys()

@spec allowed_meta_keys() :: [atom()]

The permitted span metadata keys.

event(name, measurements, meta)

@spec event([atom(), ...], map(), map()) :: :ok

Emit a manual :telemetry.execute/3 event with allowlist-validated metadata, for lazy operations (streaming) whose lifetime does not fit span/3's synchronous callback. Off-allowlist metadata keys raise (no statement/params/values/db name).

span(op, start_meta, fun)

@spec span(atom(), map(), (-> {term(), map()})) :: term()

Runs fun inside :telemetry.span([:arcadic, op], …). fun returns {result, stop_meta}; every start/stop metadata key MUST be in the allowlist or an ArgumentError is raised.