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. A table whose builder returned no rows emits neither:startnor:stop.- Measurements:
:system_time - Metadata:
:table_name,:batch_size,:concurrency,:timeout,:atomic
- Measurements:
[:blink, :copy, :stop]— emitted when the table's copy — including its sequence reset, withreset_sequences: true— completes. A failed copy emits no:stop(and there is no copy exception event): insideBlink.Seeder.run/3the failure surfaces through the[:blink, :run]span, while for a directBlink.copy_to_table/4call the raised exception is the only failure signal. In an atomic run the event fires inside the transaction, so a later table's failure can still roll the counted rows back —:stopreports a completed copy, not a commit.- 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 seed progress from these events; its
documentation lists which level each line uses:
[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 and stop are logged at level; run and build failures at
:error; build and copy completions 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.