Packages

Metrix is a library to log custom application metrics, in a well-structured, human *and* machine readable format, for use by downstream log processing systems (like Librato, Reimann, etc...)

Current section

Files

Jump to
metrix lib modifiers.ex
Raw

lib/modifiers.ex

defmodule Metrix.Modifiers do
@moduledoc """
This could hold any modifiers. Perhaps a more generic approach would
be to allow the configuration of each metric format.
This could be merged into the Metrix.Context by giving the context a
namespace within the map.
"""
@doc """
Starts the agent.
"""
def start_link(initial_modifiers) do
Agent.start_link(fn -> initial_modifiers end, name: __MODULE__)
end
@doc """
Get the metric prefix.
"""
def get_prefix do
Agent.get(__MODULE__, &Map.get(&1, :prefix))
end
@doc """
Sets the metric prefix
"""
def put_prefix(prefix) do
Agent.update(__MODULE__, &Map.put(&1, :prefix, prefix))
end
@doc """
Clear the metric prefix
"""
def clear_prefix do
Agent.update(__MODULE__, &Map.delete(&1, :prefix))
end
end