Skip to main content

lib/pdf_ex/telemetry.ex

defmodule PdfEx.Telemetry do
  @moduledoc """
  The telemetry events PdfEx emits, and the single source of truth for their
  names. Attach handlers with `:telemetry.attach/4` (or `attach_many/4`).

  Every event is emitted via `:telemetry.span/3`, so each name below actually
  fires `:start`, `:stop`, and (on failure) `:exception` suffixed events with
  the standard span measurements (`:monotonic_time`, `:duration`).

    * `[:pdf_ex, :serialize]` — wraps `PdfEx.Serializer.serialize/2`.
      Metadata: `%{dirty: non_neg_integer(), mode: :incremental | :full}`.
    * `[:pdf_ex, :session, :apply]` — wraps each applied session write
      (both `PdfEx.Session.apply_op/2` and `submit_op/2`).
      Metadata: `%{document_id: term()}`.
  """

  @serialize [:pdf_ex, :serialize]
  @session_apply [:pdf_ex, :session, :apply]

  @doc "Event prefix for `PdfEx.Serializer.serialize/2`."
  @spec serialize() :: [atom()]
  def serialize, do: @serialize

  @doc "Event prefix for session write application."
  @spec session_apply() :: [atom()]
  def session_apply, do: @session_apply
end