stats_agg v0.1.5 Ciroque.Monitoring.StatsAggMacros
This module contains macro definitions that make
using the Ciroque.Monitoring.StatsAgg
module easier.
By including this module with: use Ciroque.Monitoring.StatsAggMacros
in your modules you can instrument your functions.
Example
defmoule MyApp.MyModule do
use Ciroque.Monitoring.StatsAggMacros
end
Summary
Macros
Returns a tuple containing the module name and the current function as strings
Allows easy use of the StatsAgg library to track function execution times
Macros
Allows easy use of the StatsAgg library to track function execution times.
Example
iex> Ciroque.Monitoring.StatsAgg.start_link()
iex> defmodule MyApp.MyModule do
alias Ciroque.Monitoring.StatsAgg
require Logger
use Ciroque.Monitoring.StatsAggMacros
def group_name() do
"MyGroup"
end
def my_function() do
with_stats_agg(group_name()) do
for i <- 1..10_000, do: %{ index: i, mapped: rem(i, 10) }
end
end
def log_stats() do
group = group_name()
stats = StatsAgg.retrieve_stats([group])
IO.inspect(stats)
end
end
iex> for _ <- 1..7, do: MyApp.MyModule.my_function()
iex> MyApp.MyModule.log_stats()
Note that the group
parameter can be used to associate entries. The idea is
that by using groups it becomes easier to create groupings of StatsAgg stats
for display on some manner of Information Radiator.
Results of the StatsAgg.retrieve_stats/1
function can be exposed via web endpoint to feed
dashboards and the like.