Telemetry events emitted by Huginn, and an optional default logger.
Every request issued through Huginn.Clickhouse.Client is wrapped in a
:telemetry span:
| Event | Measurements | Metadata |
|---|---|---|
[:huginn, :query, :start] | :system_time, :monotonic_time | :method, :sql, :query_id, :pool, :telemetry_span_context |
[:huginn, :query, :stop] | :duration, :monotonic_time | start metadata + :stats and :rows, or :error, or :halted |
[:huginn, :query, :exception] | :duration, :monotonic_time | start metadata + :kind, :reason, :stacktrace |
[:huginn, :query, :retry] | :attempt, :delay | :method, :sql, :query_id, :pool, :error |
:method is one of :query, :insert, :insert_stream, :stream_query,
:stream_io. :query_id is the ID the query runs under on the server. It
is generated up front unless you pass :query_id. Durations are in
:native time units (use System.convert_time_unit/3).
:stop metadata depends on how the request ended:
- success -
:statsis the server's final statistics (ornil) and:rowsisstats.rows, the number of result rows (only when the server sent statistics) - failure -
:erroris theHuginn.Error - a stream the consumer stopped early -
halted: true
stream_query/2 and stream_io/3 are lazy: their :start is emitted when
enumeration begins, and :stop (or :exception) when it ends, so
:duration covers the whole enumeration.
[:huginn, :query, :retry] fires before each retry of a :connection
failure. :attempt is the attempt that just failed (1-based), :delay is
the backoff in milliseconds.
Default logger
Attach a ready-made handler that logs each completed request:
Huginn.attach_default_logger()
# or with a level
Huginn.attach_default_logger(:debug)Detach it with detach_default_logger/0.
Summary
Functions
Attaches a default Logger handler for Huginn query events.
Detaches the default logger attached by attach_default_logger/1.
Functions
@spec attach_default_logger(Logger.level()) :: :ok | {:error, :already_exists}
Attaches a default Logger handler for Huginn query events.
level is the log level used for successful queries (default: :info);
failures and exceptions are always logged at :error. Returns :ok, or
{:error, :already_exists} if already attached.
@spec detach_default_logger() :: :ok | {:error, :not_found}
Detaches the default logger attached by attach_default_logger/1.