Skip to content

Commit

Permalink
Merge pull request xerions#24 from surik/fix_ids_for_function
Browse files Browse the repository at this point in the history
Fix exometer ids for function type entries
  • Loading branch information
GalaxyGorilla authored Jul 28, 2016
2 parents e02df13 + 2758268 commit e408d43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ defmodule Metricman.Subscription do
(id, acc) -> acc ++ [id]
end)
opts = Keyword.merge(@opts, unquote(opts))
path |> result(metric_type, unquote(exo_id), vars, opts)
path |> result(metric_type, unquote(exo_id_for_match), vars, opts)
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/subscription_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule MetricmanSubscribtionTest do
scope [:region, "$city"] do # it is posible to use list and string as variable name
map [:used], [:ippools, :ip, '$country', '$city', :used]
map [:total], [:ippools, :ip, "$country", "$city", :total]
map [:func], [:ippools, :ip, "$country", "$city", :func]
end
map [:used], [:ippools, :ip, '$country', :used]
map [:total], [:ippools, :ip, '$country', :total]
Expand All @@ -36,11 +37,15 @@ defmodule MetricmanSubscribtionTest do
:exometer.new([:ippools, :ip, :ru, :nsk, :used], :counter)
:exometer.new([:ippools, :ip, :ru, :nsk, :total], :counter)
:exometer.new([:ippools, :ip, :ru, :req], :histogram)
:exometer.new([:ippools, :ip, :ru, :nsk, :func],
{:function, __MODULE__, :test_func, [], :proplist, [:value, :value2]}, [])
on_exit fn ->
for {name, _} <- :exometer.get_values([:ippools]), do: :exometer.delete(name)
end
end

def test_func(), do: [value: 1]


test "get not found" do
assert {:error, :not_found} == TestModule.get([:macpools, :mac, :mactotal, :used], :counter)
Expand Down Expand Up @@ -70,5 +75,7 @@ defmodule MetricmanSubscribtionTest do
== TestModule.get([:ippools, :ip, :ru, :nsk, :used], :counter)
assert {:ok, {[:ipPools, :ru, :region, :nsk, :total], [:value], @opts1}}
== TestModule.get([:ippools, :ip, :ru, :nsk, :total], :counter)
assert {:ok, {[:ipPools, :ru, :region, :nsk, :func], [:value, :value2], @opts1}}
== TestModule.get([:ippools, :ip, :ru, :nsk, :func], :function)
end
end

0 comments on commit e408d43

Please sign in to comment.