diff --git a/config/test.exs b/config/test.exs index 0231c27..08193bd 100644 --- a/config/test.exs +++ b/config/test.exs @@ -3,6 +3,7 @@ use Mix.Config # setting the statsd port to something other than the default # in test so we don't conflict in the build env. config :instruments, + statsd_host: "localhost", statsd_port: 15310, fast_counter_report_interval: 10, fast_counter_report_jitter_range: 0..0, diff --git a/lib/instruments.ex b/lib/instruments.ex index 953d13a..efabbe7 100644 --- a/lib/instruments.ex +++ b/lib/instruments.ex @@ -66,6 +66,13 @@ defmodule Instruments do end end + @doc false + def statsd_host do + :instruments + |> Application.get_env(:statsd_host, "localhost") + |> String.to_charlist() + end + @doc false def statsd_port(), do: @statsd_port @@ -203,7 +210,7 @@ defmodule Instruments do # this will have to be changed. unquote(@metrics_module) |> Process.whereis() - |> :gen_udp.send('localhost', Instruments.statsd_port(), message) + |> :gen_udp.send(Instruments.statsd_host(), Instruments.statsd_port(), message) end end diff --git a/pages/Configuration.md b/pages/Configuration.md index 7f7c28b..152b484 100644 --- a/pages/Configuration.md +++ b/pages/Configuration.md @@ -28,7 +28,9 @@ There are a couple of `Instruments` specific application variables: * `fast_counter_report_jitter_range`: How much random jitter should be applied to the reporting interval, in milliseconds. Defaults to half a second before and after the reporting interval. * `probe_prefix`: A global prefix to apply to all probes. -* `statsd_port`: The port that the statsd server listens on. Should be the same as the port in the statix +* `statsd_host`: The hostname of the statsd server. Defaults to `"localhost"`. Should be the same as the host + in the statix configuration above. +* `statsd_port`: The port that the statsd server listens on. Should be the same as the port in the statix configuration above. * `enable_sysmon`: Enables and registers `Instruments.Sysmon.Reporter` with `:erlang.system_monitor/1` to receive system monitor events. @@ -42,4 +44,5 @@ For example: fast_counter_report_interval: 30_000, fast_counter_report_jitter_range: -700..700, probe_prefix: "probes", + statsd_host: "localhost", statsd_port: 15339