GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - restorando/statue: Easily track application metrics into Statsite

BranchesTags
Open more actions menu

Latest commit

 

History

59 Commits
59 Commits

Folders and files

NameName
Last commit message
Last commit date
bin
bin
 
 
lib
lib
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Gemfile
Gemfile
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
statue.gemspec
statue.gemspec
 
 

Repository files navigation

Statue

Build Status

/ ___)(_  _)/ _\(_  _)/ )( \(  __)
\___ \  )( /    \ )(  ) \/ ( ) _)
(____/ (__)\_/\_/(__) \____/(____)

Rock solid metrics report...

Easily track application metrics into Statsite (Statsd compatible).

Configuration

The library has different backends, one to be used for production environment (ie. actually sending metrics using the Statsd protocol), and the others for testing or developing.

The available backends are:

Statue::UDPBackend -> this is the one that actually sends metrics to the Statsd.

eg.

Statue.backend = Statue::UDPBackend.new(statsd_host, statsd_port)

Statue::NullBackend, this backend discards all metrics (useful for test environment, if you aren't interested in testing which metrics are sent).

Statue::CaptureBackend, this backend collects all metrics (useful for test environment, if you arent interested in testing which metrics are sent). You can check the metrics with Statue.backend.captures and reset this array with Statue.backend.captures.clear or by setting a new instance before each test.

Statue::LoggerBackend, this backend logs the received metrics to a logger (useful for development purposes)

eg.

Statue.backend = Statue::LoggerBackend.new(Rails.logger)

Usage

Common measurements

Statue.report_increment('metric.name') -> send to Statsd an increment to the counter metric.name

Statue.report_gauge('metric.name', value) -> send to Statsd the gauge value for metric.name

Statue.report_duration('metric.name') { some_operation } # => some_operation_result -> send to Statsd the measure for the block duration in metric.name

Statue.report_success_or_failure('metric.name') { some_operation } # => some_operation_result -> checks the result of the block, if its a truthy value, then increments metric.name.success, else it increments metric.name.failure.

Stopwatch

The stopwatch provides an easy way to track the duration of a long process with multiple phases.

stopwatch = Statue.stopwatch("metric") # => Starts tracking time

while something do
  do_something
  stopwatch.partial # => reports duration from last partial until now as: "metric.runtime.partial"
end

stopwatch.stop # => reports duration from start until now as: "metric.runtime.total"

Rack Integration

We provide a middleware to track basic request metrics, see: Statue::RackStatistics

Sidekiq Integration

There's also a middleware for Sidekiq, which can easily be added by adding these lines to the initializer:

# config/initializers/sidekiq.rb

Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.add Statue::SidekiqStatistics::SidekiqMiddleware
  end
end

Contributing

  1. Fork it ( https://github.com/restorando/statue/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Easily track application metrics into Statsite

Topics

instrumentationmetricsrubysending-metricsstatsd

Resources

Readme
MIT license
Activity
Custom properties

Stars

9 stars

Watchers

25 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.