Packages
legendary_core
2.6.0
8.12.0
8.11.1
8.11.0
8.10.0
8.9.2
8.9.1
8.5.3
8.5.2
8.5.1
8.5.0
8.4.0
8.3.6
8.3.5
8.3.4
8.3.3
8.3.2
8.3.1
8.3.0
8.2.7
8.2.5
8.2.4
8.2.3
8.2.2
8.2.1
8.2.0
8.1.1
8.1.0
8.0.1
8.0.0
7.17.12
7.17.8
7.17.7
7.17.6
7.17.5
7.17.4
7.17.3
7.17.2
7.17.1
7.17.0
7.16.12
7.16.11
4.5.4
4.0.0
2.12.0
2.11.5
2.6.0
2.4.1
2.4.0
2.3.7
2.1.2
A PETAL-stack batteries-included boilerplate for making Phoenix apps without tedium.
Current section
Files
Jump to
Current section
Files
lib/core_web/telemetry.ex
defmodule Legendary.CoreWeb.Telemetry do
@moduledoc """
Collects metrics for the application and allows them to be transmitted using the Telemetry framework.
"""
use Supervisor
import Telemetry.Metrics
def start_link(arg) do
Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
end
@impl true
def init(_arg) do
children = [
# Telemetry poller will execute the given period measurements
# every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics
{:telemetry_poller, measurements: periodic_measurements(), period: 10_000}
# Add reporters as children of your supervision tree.
# {Telemetry.Metrics.ConsoleReporter, metrics: metrics()}
]
Supervisor.init(children, strategy: :one_for_one)
end
def metrics do
[
# Phoenix Metrics
summary("phoenix.endpoint.stop.duration",
unit: {:native, :millisecond}
),
summary("phoenix.router_dispatch.stop.duration",
tags: [:route],
unit: {:native, :millisecond}
),
# Database Metrics
summary("core.repo.query.total_time", unit: {:native, :millisecond}),
summary("core.repo.query.decode_time", unit: {:native, :millisecond}),
summary("core.repo.query.query_time", unit: {:native, :millisecond}),
summary("core.repo.query.queue_time", unit: {:native, :millisecond}),
summary("core.repo.query.idle_time", unit: {:native, :millisecond}),
# VM Metrics
summary("vm.memory.total", unit: {:byte, :kilobyte}),
summary("vm.total_run_queue_lengths.total"),
summary("vm.total_run_queue_lengths.cpu"),
summary("vm.total_run_queue_lengths.io")
]
end
defp periodic_measurements do
[
# A module, function and arguments to be invoked periodically.
# This function must call :telemetry.execute/3 and a metric must be added above.
# {Legendary.CoreWeb, :count_users, []}
]
end
end