Application that generate metrics about Verk jobs & queues through a sink
(logs, statsd)
The package can be installed by adding verk_stats
to your list of dependencies in mix.exs
:
def deps do
[
{:verk_stats, "~> 1.0"}
]
end
jobs.start
-counter
- When a job was startedjobs.success
-timing
- How long a job took to finish successfully.jobs.success.total_fime
-timing
- How long a job took to finish successfully counting from the time it was enqueued.jobs.failure
-timing
- How long it took for a job to finish unsuccessfully.
Every metric will have tags "worker:NameOfWorker"
& "queue:NameOfTheQueue"
Add VerkStats
to your supervision tree after Verk.Supervisor
has been started.
Example using LoggerSink
as sink.
defmodule VerkExample do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [supervisor(Verk.Supervisor, []), {VerkStats, VerkStats.LoggerSink}]
opts = [strategy: :one_for_one, name: VerkExample.Supervisor]
Supervisor.start_link(children, opts)
end
end
The LoggerSink
will log all metrics. Here's an example of a sink using Statix
(StatsD client):
defmodule StatixSink do
@behaviour VerkStats.Sink
use Statix
def collect(:counter, key, value, tags) do
increment(key, value, tags: tags)
:ok
end
def collect(:timing, key, value, tags) do
timing(key, value, tags: tags)
:ok
end
end