prometheus_ecto

Ecto query duration metrics for Prometheus.
pull/841/head
Luke Imhoff 6 years ago
parent 9dde152e27
commit 32380ba1e9
  1. 4
      apps/explorer/config/config.exs
  2. 2
      apps/explorer/config/dev.secret.exs.example
  3. 4
      apps/explorer/lib/explorer/application.ex
  4. 9
      apps/explorer/lib/explorer/repo/prometheus_logger.ex
  5. 2
      apps/explorer/mix.exs
  6. 1
      mix.lock

@ -18,7 +18,9 @@ config :explorer, Explorer.ExchangeRates, enabled: true
config :explorer, Explorer.Market.History.Cataloger, enabled: true
config :explorer, Explorer.Repo, migration_timestamps: [type: :utc_datetime]
config :explorer, Explorer.Repo,
loggers: [Explorer.Repo.PrometheusLogger, Ecto.LogEntry],
migration_timestamps: [type: :utc_datetime]
config :explorer,
solc_bin_api_url: "https://solc-bin.ethereum.org"

@ -7,7 +7,7 @@ config :explorer, Explorer.Repo,
hostname: "localhost",
username: "postgres",
password: "<REPLACE WITH THE PASSWORD YOU CHOSE>",
loggers: [],
loggers: [Explorer.Repo.PrometheusLogger],
pool_size: 20,
pool_timeout: 60_000,
timeout: 80_000

@ -5,8 +5,12 @@ defmodule Explorer.Application do
use Application
alias Explorer.Repo.PrometheusLogger
@impl Application
def start(_type, _args) do
PrometheusLogger.setup()
# Children to start in all environments
base_children = [
Explorer.Repo,

@ -0,0 +1,9 @@
defmodule Explorer.Repo.PrometheusLogger do
@moduledoc """
Log `Ecto` query durations as `Prometheus` metrics.
"""
@dialyzer {:no_match, [log: 1, setup: 0]}
use Prometheus.EctoInstrumenter
end

@ -91,6 +91,8 @@ defmodule Explorer.Mixfile do
{:mock, "~> 0.3.0", only: [:test], runtime: false},
{:mox, "~> 0.4", only: [:test]},
{:postgrex, ">= 0.0.0"},
# Prometheus metrics for query duration
{:prometheus_ecto, "~> 1.3"},
{:sobelow, ">= 0.7.0", only: [:dev, :test], runtime: false},
{:timex, "~> 3.1.24"},
{:timex_ecto, "~> 3.2.1"}

@ -70,6 +70,7 @@
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []},
"postgrex": {:hex, :postgrex, "0.13.5", "3d931aba29363e1443da167a4b12f06dcd171103c424de15e5f3fc2ba3e6d9c5", [:mix], [{:connection, "~> 1.0", [hex: :connection, optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}]},
"prometheus": {:hex, :prometheus, "4.2.0", "06c58bfdfe28d3168b926da614cb9a6d39593deebde648a5480e32dfa3c370e9", [:mix, :rebar3], [], "hexpm"},
"prometheus_ecto": {:hex, :prometheus_ecto, "1.3.0", "fe65de16bcfdd6e3c5455194368cd2c7a7034f734a12c12cb9471f4d5e7690c9", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm"},
"prometheus_ex": {:hex, :prometheus_ex, "3.0.3", "5d722263bb1f7a9b1d02554de42e61ea672b4e3c07c3f74e23ce35ab5e111cfa", [:mix], [{:prometheus, "~> 4.0", [hex: :prometheus, repo: "hexpm", optional: false]}], "hexpm"},
"prometheus_phoenix": {:hex, :prometheus_phoenix, "1.2.1", "964a74dfbc055f781d3a75631e06ce3816a2913976d1df7830283aa3118a797a", [:mix], [{:phoenix, "~> 1.3", [hex: :phoenix, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.3 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm"},
"prometheus_plugs": {:hex, :prometheus_plugs, "1.1.5", "25933d48f8af3a5941dd7b621c889749894d8a1082a6ff7c67cc99dec26377c5", [:mix], [{:accept, "~> 0.1", [hex: :accept, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}, {:prometheus_process_collector, "~> 1.1", [hex: :prometheus_process_collector, repo: "hexpm", optional: true]}], "hexpm"},

Loading…
Cancel
Save