You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A client for DogStatsd, an extension of the StatsD metric server for Datadog.
Quick Start Guide
First install the library:
Add dogstatsd to your mix.exs dependencies:
defdepsdo[{:dogstatsd,"0.0.3"}]end
Add :dogstatsd to your application dependencies:
defapplicationdo[applications: [:dogstatsd]]end
Then start instrumenting your code:
# Require the dogstatsd module.requireDogStatsd# Configure DogStatsd.{:ok,statsd}=DogStatsd.new("localhost",8125)# Increment a counter.DogStatsd.increment(statsd,"page.views")# Record a gauge 50% of the time.DogStatsd.gauge(statsd,"users.online",123,%{sample_rate: 0.5})# Sample a histogramDogStatsd.histogram(statsd,"file.upload.size",1234)# Time a block of codeDogStatsd.time(statsd,"page.render")dorender_page('home.html')end# Send several metrics at the same time# All metrics will be buffered and sent in one packet when the block completesDogStatsd.batch(statsd,fn(s)->s.increment(statsd,"page.views")s.gauge(statsd,"users.online",123)end)# Tag a metric.DogStatsd.histogram(statsd,"query.time",10,%{tags: ["version:1"]})
You can also post events to your stream. You can tag them, set priority and even aggregate them with other events.
Aggregation in the stream is made on hostname/event_type/source_type/aggregation_key.
# Post a simple messageDogStatsd.event(statsd,"There might be a storm tomorrow","A friend warned me earlier.")# Cry for helpDogStatsd.event(statsd,"SO MUCH SNOW","Started yesterday and it won't stop !!",%{alert_type: "error",tags: ["urgent","endoftheworld"]})
Feedback
To suggest a feature, report a bug, or general discussion, head over
here.