GitHoox.Telemetry (GitHoox v0.4.1)

Copy Markdown View Source

:telemetry event emission for GitHoox.

GitHoox emits two pairs of :telemetry events: one around each stage, one around each individual hook invocation. Events are emitted unconditionally; no handler is attached by default. Attach GitHoox.Logger for the reference console output, or attach your own handler for custom routing.

Events

[:git_hoox, :stage, :start | :stop | :exception]

Wraps a stage run from GitHoox.Runner.run/3.

  • :start measurements — %{system_time: integer()}
  • :stop measurements — %{duration: integer()} (native time units)
  • Metadata (:start and :stop) — %{stage: atom(), entries: non_neg_integer(), files: non_neg_integer()}
  • :stop metadata also carries %{result: :ok | :error, failures: non_neg_integer()}

[:git_hoox, :hook, :start | :stop | :exception]

Wraps a single hook invocation.

  • Measurements as for the stage events.
  • Metadata — %{stage: atom(), module: module(), files: non_neg_integer()}
  • :stop metadata also carries %{result: :ok | :skip | :error, error: term() | nil}

Example handler

:telemetry.attach(
  "my-hook-logger",
  [:git_hoox, :hook, :stop],
  fn _event, %{duration: d}, %{module: mod, result: r}, _ ->
    ms = System.convert_time_unit(d, :native, :millisecond)
    IO.puts("#{inspect(mod)}#{r} in #{ms}ms")
  end,
  nil
)