Skip to content

sb8244/statsd_logger

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

StatsD Logger opens a UDP port and prints out StatsD messages to STDOUT

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages