Telemetry events emitted by Blink, and a default logger built on them.
Attach the default logger in your seed script to get progress logging without writing any timing code:
Blink.Telemetry.attach_default_logger()
MyApp.Seeder.call()Events
Build events
Table and context builders run when they are declared — with_table/2 and
with_context/2 call your table/2 or context/2 clause immediately — so
build time is reported per declaration, not as part of the run span below.
[:blink, :build, :start]— emitted when a builder starts.- Measurements:
:system_time,:monotonic_time - Metadata:
:callback(:tableor:context),:key(the declared name)
- Measurements:
[:blink, :build, :stop]— emitted when a builder returns.- Measurements:
:duration,:monotonic_time - Metadata: as for
:start
- Measurements:
[:blink, :build, :exception]— emitted when a builder raises.- Measurements:
:duration,:monotonic_time - Metadata: as for
:start, plus:kind,:reason, and:stacktraceof the error
- Measurements:
A builder that returns a stream reports a near-zero duration here; its rows are produced during the copy instead.
Run events
A span around Blink.Seeder.run/3 — the copy phase of the seed.
[:blink, :run, :start]- Measurements:
:system_time,:monotonic_time - Metadata:
:repo,:tables(declared names in insertion order),:atomic
- Measurements:
[:blink, :run, :stop]- Measurements:
:duration,:monotonic_time - Metadata: as for
:start
- Measurements:
[:blink, :run, :exception]- Measurements:
:duration,:monotonic_time - Metadata: as for
:start, plus:kind,:reason,:stacktrace
- Measurements:
Copy events
Emitted by Blink.Adapter.Postgres for each table copied.
[:blink, :copy, :start]— emitted once per table, before the first batch is written.- Measurements:
:system_time - Metadata:
:table_name,:batch_size,:concurrency,:timeout,:atomic
- Measurements:
[:blink, :copy, :stop]— emitted when the table's copy completes.- Measurements:
:duration,:row_count - Metadata: as for
:start
- Measurements:
Durations are in :native time units; convert with
System.convert_time_unit(duration, :native, :millisecond).
Default logger
attach_default_logger/1 logs run start, stop, and failure at the given
level (default :info), and per-declaration build times and per-table copy
times at :debug:
[info] Seeding MyApp.Repo (3 tables)...
[debug] Copied 1000 rows into "users" in 12 ms
[info] Seeded MyApp.Repo (3 tables) in 87 ms
Summary
Functions
Attaches a logger to Blink's telemetry events.
Detaches the logger attached by attach_default_logger/1.
Functions
@spec attach_default_logger(level :: Logger.level()) :: :ok | {:error, :already_exists}
Attaches a logger to Blink's telemetry events.
Run start, stop, and failure are logged at level; build and copy
completions are logged at :debug. Returns {:error, :already_exists} if
the logger is already attached.
@spec detach_default_logger() :: :ok | {:error, :not_found}
Detaches the logger attached by attach_default_logger/1.
Returns {:error, :not_found} if it is not attached.