Skip to content
Opens a UDP port and prints out StatsD messages to STDOUT
Elixir
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.formatter.exs
.gitignore
LICENSE
README.md
mix.exs
mix.lock

README.md

StatsDLogger

StatsDLogger prints (to stdout) any StatsD metrics sent to it. It is a simple UDP server which looks for messages separated by a single :.

This is meant for development purposes and doesn't serve any production value.

Installation

This package can be installed by adding statsd_logger to your list of dependencies in mix.exs:

def deps do
  [
    {:statsd_logger, "~> 1.0.0"}
  ]
end

Usage

StatsDLogger will automatically start when a port is configured for it:

config :statsd_logger, port: 8126

You can manually start StatsDLogger in your supervision tree as well:

StatsDLogger.start_link(port: 8126)

You will see STDOUT printed messages. This is done to allow the message to be seen separate of your other logs in development.

Test Usage

It's possible to use StatsDLogger for tests. You can do so by using the :send formatter. This will deliver messages to the current process. See this sample for an example of how to use it:

test "valid / invalid messages are handled" do
  StatsDLogger.start_link(port: 8130, formatter: :send)

  send_event("a:1")
  send_event("a:2|c")
  send_event("invalid")

  assert_receive {:statsd_recv, "a", "1"}
  assert_receive {:statsd_recv, "a", "2|c"}
  assert_receive {:statsd_recv_invalid, "invalid"}
end
You can’t perform that action at this time.