Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metrics-instrument

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metrics-instrument

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Metrics client for Ruby apps

Adaptation of statsd-instrument for the (yet unreleased) metrics server.

Configuration

Metrics.server = 'statsd.myservice.com:8125'
Metrics.logger = Rails.logger
Metrics.mode = :production
Metrics.default_sample_rate = 0.1 # Sample 10% of events. By default all events are reported.

Usage

Metrics.measure

# You can pass a key and a ms value
Metrics.measure('GoogleBase.insert', 2.55)

# or more commonly pass a block that calls your code
Metrics.measure('GoogleBase.insert') do
  GoogleBase.insert(product)
end

or with metaprogramming:

GoogleBase.extend Metrics::Instrument
GoogleBase.metrics_measure :insert, 'GoogleBase.insert'

Metaprogramming methods

  • metrics_count adds '1' to the metric
  • metrics_count_if adds '1' to the metric if method returned something that evaulates to true. Takes optional block to evaluate the returned value.
  • metrics_count_success adds '1' to metric.success for successful calls and metrics.failure for failed calls.

FAQs

Package last updated on 02 Mar 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc