Telemetry events emitted by PgFlow.
PgFlow uses :telemetry to emit events at key points in the workflow lifecycle.
These events can be used for monitoring, logging, and metrics collection.
Events
Worker Lifecycle
[:pgflow, :worker, :start]— Worker process started[:pgflow, :worker, :stop]— Worker process stopped
Poll Cycles
[:pgflow, :worker, :poll, :start]— Poll cycle started[:pgflow, :worker, :poll, :stop]— Poll cycle completed
Task Execution
[:pgflow, :worker, :task, :start]— Task execution started[:pgflow, :worker, :task, :stop]— Task execution completed successfully[:pgflow, :worker, :task, :exception]— Task execution failed
Run Lifecycle
[:pgflow, :run, :started]— Flow run created (emitted byPgFlow.Client)[:pgflow, :run, :completed]— Flow run completed (emitted by worker after task cascades)[:pgflow, :run, :failed]— Flow run failed (emitted by worker after task cascades)
Attaching Handlers
:telemetry.attach_many(
"my-handler",
[
[:pgflow, :worker, :task, :stop],
[:pgflow, :run, :completed],
[:pgflow, :run, :failed]
],
&MyModule.handle_event/4,
nil
)Default Logger
PgFlow includes a default logger handler that can be attached by setting
attach_default_logger: true in the configuration.
Note: The default logger is disabled by default since PgFlow.Logger provides
structured logging directly in the worker. Enable this if you need telemetry-based
logging for specific use cases like metrics collection or external log aggregation.
Summary
Functions
Attaches the default telemetry handlers for logging.
Detaches the default telemetry handlers.
Functions
@spec attach_default_logger() :: :ok | {:error, :already_exists}
Attaches the default telemetry handlers for logging.
This is called automatically on application start if attach_default_logger: true
is set in the configuration.
@spec detach_default_logger() :: :ok | {:error, :not_found}
Detaches the default telemetry handlers.