Skip to content

edgurgel/verk-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VerkStats Build Status

Application that generate metrics about Verk jobs & queues through a sink (logs, statsd)

Installation

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

Metrics

  • jobs.start - counter - When a job was started
  • jobs.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"

Usage

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