Socket
Book a DemoInstallSign in
Socket

http_statsd

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http_statsd

0.0.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

HttpStatsd

Build Status

HttpStatsd provides a HTTP proxy for the statsd protocol. The use case is when you need to collect metrics from an external source, but for obvious reasons don't want to expose the udp interface of statsd.

It also provides a client for that proxy for easy integration with Ruby code.

Installation

Add this line to your application's Gemfile:

gem 'http_statsd'

And then execute:

$ bundle

Or install it yourself as:

$ gem install http_statsd

Usage

Server

There is an example config.ru file included in the repo. To use the proxy, you need to provide at least one api key, with:

HttpStatsd::Server.set :api_keys, {
  "username1" => "pass1",
  "username2" => "pass2"
}

You can also set the statsd server host and port (default is "localhost:8125"):

HttpStatsd::Server.set :statsd_host, "statsd.example.com"
HttpStatsd::Server.set :statsd_port, 8125

Client

To access the server, you can use the built in client:

c = HttpStatsd::Client.new(base_uri: "http://statsd.example.com",
                           username: "username1", password: "pass1")

Then, you can use the same interface as with the statsd-ruby gem:

sample_rate = 0.1
c.increment("metric.counter", sample_rate)
c.decrement("metric.counter", sample_rate)
c.count("metric.counter", 121, sample_rate)
c.gauge("metric.gauge", 123)
c.timing("metric.timing", 15.52, sample_rate)
c.batch do |b| # this will send the metrics as one http request
  b.increment("metric.counter")
  b.gauge("metric.gauge", 120)
end

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 06 Oct 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.