Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion lib/instruments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ defmodule Instruments do
end
end

@doc false
def statsd_host do
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we only know our hostname at runtime, we can't have this one be a module attribute like the statsd_port

:instruments
|> Application.get_env(:statsd_host, "localhost")
|> String.to_charlist()
end

@doc false
def statsd_port(), do: @statsd_port

Expand Down Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion pages/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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