ExDatalog.Telemetry (ExDatalog v0.2.0)

Copy Markdown View Source

Telemetry event definitions for ExDatalog evaluation.

All events follow :telemetry library conventions. Attach handlers using :telemetry.attach/4 or :telemetry.attach_many/4.

Events

EventWhenMeasurementsMetadata
[:ex_datalog, :query, :start]Before evaluation%{system_time: ...}%{relation_count: ..., stratum_count: ...}
[:ex_datalog, :query, :stop]After evaluation%{duration: ..., iterations: ...}%{relation_sizes: ..., stratum_count: ..., storage_type: ...}
[:ex_datalog, :query, :exception]On exception%{duration: ...}%{kind: ..., reason: ..., stacktrace: ..., stratum_count: ...}

The :start event fires before evaluation begins. The :stop event fires after evaluation completes (success or error). The :exception event fires only when an exception terminates evaluation.

Zero-overhead when no handlers attached

:telemetry.execute/3 checks the handler table before any work, so unattached events are effectively free.

Summary

Functions

Emits the [:ex_datalog, :query, :exception] event.

Emits the [:ex_datalog, :query, :start] event.

Returns the [:ex_datalog, :query, :exception] event name.

Returns the [:ex_datalog, :query, :start] event name.

Returns the [:ex_datalog, :query, :stop] event name.

Functions

emit_exception(start_time, kind, reason, stacktrace, stratum_count)

@spec emit_exception(integer(), Exception.kind(), term(), list(), non_neg_integer()) ::
  :ok

Emits the [:ex_datalog, :query, :exception] event.

Called when an exception terminates evaluation. The kind, reason, and stacktrace should come from __STACKTRACE__ inside a rescue or catch.

Measurements

  • :duration — elapsed time in microseconds before the exception.

Metadata

  • :kind — exception kind (:error, :exit, :throw).
  • :reason — exception reason.
  • :stacktrace — the stacktrace.
  • :stratum_count — number of strata in the program.

emit_start(ir)

@spec emit_start(ExDatalog.IR.t()) :: :ok

Emits the [:ex_datalog, :query, :start] event.

Called before evaluation begins.

Measurements

  • :system_time — monotonic time in native units.

Metadata

  • :relation_count — number of relations in the IR program.
  • :stratum_count — number of strata.

emit_stop(start_time, iterations, relation_sizes, stratum_count, storage_type)

@spec emit_stop(
  integer(),
  non_neg_integer(),
  %{required(String.t()) => non_neg_integer()},
  non_neg_integer(),
  atom()
) :: :ok

Emits the [:ex_datalog, :query, :stop] event.

Called after evaluation completes (success or error). The start_time argument should be the System.monotonic_time(:microsecond) value captured before evaluation started.

Measurements

  • :duration — elapsed time in microseconds.
  • :iterations — total fixpoint iterations across all strata.

Metadata

  • :relation_sizes — map of relation name to tuple count.
  • :stratum_count — number of strata.
  • :storage_type — the storage backend type (:map, :ets, or :external).

query_exception()

@spec query_exception() :: [:ex_datalog | :query | :exception, ...]

Returns the [:ex_datalog, :query, :exception] event name.

query_start()

@spec query_start() :: [:ex_datalog | :query | :start, ...]

Returns the [:ex_datalog, :query, :start] event name.

query_stop()

@spec query_stop() :: [:ex_datalog | :query | :stop, ...]

Returns the [:ex_datalog, :query, :stop] event name.