Code Monkey home page Code Monkey logo

puma-stats-logger's Introduction

Puma Stats Logger

For Rack apps (including Rails)

This Rack middleware gathers statistics from Puma web server and logs them to the logging destination of your choice. It uses Puma's built in control server to query Puma's stats after every request in your production application. Currently, Puma provides two metrics that are output to your logs:

  • running - the number of threads currently running
  • backlog - the number of requests waiting to be processed by a thread

The actual log entry looks like this:

measure#puma.backlog=0 measure#puma.running=6

Getting Started

Add the gem to your gemfile:

gem 'puma-stats-logger'
Enable Puma's control/stats server & state file

If you use a Puma configuration file, add the following two lines:

# in config/puma.rb

activate_control_app
state_path 'tmp/puma.state'

OR ... if you don't use a Puma config file and you start Puma via command line, add these options:

puma --control auto --state "tmp/puma.state"
Activate the Middleware in your app

In your application and/or environment config:

config.middleware.use PumaStatsLogger::Middleware

or in a Rails initializer:

Rails.application.middleware.use PumaStatsLogger::Middleware
Changing the logging destination

By default, the Puma stats are logged to standard output $stdout. This works great out of the box for Heroku users. You can customize this by passing an option hash:

config.middleware.use PumaStatsLogger::Middleware, logger: Logger.new('destination/puma-stats.log')

Visualizing Results

We use the Librato add-on on Heroku to make nice charts of this data. You may have noticed that the log output is already formatted for Librato, so if you're already using Librato, Puma metrics should show up automatically under Metrics.

Puma stats in Librato

Open Source by Hired

Hired is a marketplace for top engineering talent to find full-time technology jobs. Talented Ruby developers (like yourself) are in extremely high demand! On Hired, apply once and receive 5 to 15 competing job offers in one week from 800+ technology companies. Average Ruby engineer salaries on Hired are around $120,000 per year!

Hired

We are Ruby developers ourselves, and we use all of our open source projects in production. We always encourge forks, pull requests, and issues. Get in touch with the Hired Engineering team at [email protected].

puma-stats-logger's People

Contributors

heythisisnate avatar

Watchers

Joel N avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.