EctoSparkles.Log (ecto_sparkles v0.4.0)

Copy Markdown View Source

Log Ecto queries, and output warnings for slow or possible n+1 queries

To set up, simply add EctoSparkles.Log.setup(YourApp.Repo) in your app's main Application.start/2 module.

Summary

Functions

Converts a telemetry :native time to microseconds (nil/garbage-safe: returns 0).

The telemetry event id for the repo's queries (e.g. [:bonfire, :common, :repo, :query]), derived from the repo's :telemetry_prefix config (falling back to Ecto's module-name default). The canonical helper for every consumer of the repo query event.

Functions

format_log(result_key, duration_in_ms, metadata)

handle_event(_, measurements, metadata, config)

inline_params(query, params, repo_adapter \\ Ecto.Adapters.SQL)

log_query(result_key, duration_in_ms, metadata)

native_us(t)

Converts a telemetry :native time to microseconds (nil/garbage-safe: returns 0).

query_event(repo_module)

The telemetry event id for the repo's queries (e.g. [:bonfire, :common, :repo, :query]), derived from the repo's :telemetry_prefix config (falling back to Ecto's module-name default). The canonical helper for every consumer of the repo query event.

setup(repo_module, opts \\ [])

telemetry_prefix(repo_module)