Permalink
Browse files

Create redirect branch

  • Loading branch information...
1 parent 661b64c commit 98f82196ce70fd0142ea63b6fc8d12b50ed62394 @nextmat nextmat committed Sep 10, 2012
Showing with 2 additions and 2,204 deletions.
  1. +0 −13 Gemfile
  2. +2 −101 README.md
  3. +0 −1 lib/librato-rails.rb
  4. +0 −4 lib/librato/rack.rb
  5. +0 −47 lib/librato/rack/middleware.rb
  6. +0 −209 lib/librato/rails.rb
  7. +0 −48 lib/librato/rails/aggregator.rb
  8. +0 −41 lib/librato/rails/counter_cache.rb
  9. +0 −27 lib/librato/rails/group.rb
  10. +0 −19 lib/librato/rails/helpers.rb
  11. +0 −18 lib/librato/rails/railtie.rb
  12. +0 −77 lib/librato/rails/subscribers.rb
  13. +0 −5 lib/librato/rails/version.rb
  14. +0 −58 lib/librato/rails/worker.rb
  15. +0 −4 lib/tasks/metrics-rails_tasks.rake
  16. +0 −24 librato-rails.gemspec
  17. +0 −261 test/dummy/README.rdoc
  18. +0 −7 test/dummy/Rakefile
  19. +0 −15 test/dummy/app/assets/javascripts/application.js
  20. +0 −2 test/dummy/app/assets/javascripts/home.js
  21. +0 −2 test/dummy/app/assets/javascripts/status.js
  22. +0 −13 test/dummy/app/assets/stylesheets/application.css
  23. +0 −4 test/dummy/app/assets/stylesheets/home.css
  24. +0 −4 test/dummy/app/assets/stylesheets/status.css
  25. +0 −10 test/dummy/app/controllers/application_controller.rb
  26. +0 −33 test/dummy/app/controllers/home_controller.rb
  27. +0 −5 test/dummy/app/controllers/status_controller.rb
  28. +0 −13 test/dummy/app/controllers/user_controller.rb
  29. +0 −2 test/dummy/app/helpers/application_helper.rb
  30. +0 −2 test/dummy/app/helpers/home_helper.rb
  31. +0 −2 test/dummy/app/helpers/status_helper.rb
  32. 0 test/dummy/app/mailers/.gitkeep
  33. +0 −8 test/dummy/app/mailers/user_mailer.rb
  34. 0 test/dummy/app/models/.gitkeep
  35. +0 −18 test/dummy/app/models/user.rb
  36. +0 −2 test/dummy/app/views/home/index.html.erb
  37. +0 −14 test/dummy/app/views/layouts/application.html.erb
  38. +0 −2 test/dummy/app/views/status/code.html.erb
  39. +0 −1 test/dummy/app/views/user_mailer/welcome_email.text.erb
  40. +0 −4 test/dummy/config.ru
  41. +0 −63 test/dummy/config/application.rb
  42. +0 −10 test/dummy/config/boot.rb
  43. +0 −25 test/dummy/config/database.yml
  44. +0 −5 test/dummy/config/environment.rb
  45. +0 −37 test/dummy/config/environments/development.rb
  46. +0 −67 test/dummy/config/environments/production.rb
  47. +0 −37 test/dummy/config/environments/test.rb
  48. +0 −7 test/dummy/config/initializers/backtrace_silencers.rb
  49. +0 −15 test/dummy/config/initializers/inflections.rb
  50. +0 −5 test/dummy/config/initializers/mime_types.rb
  51. +0 −7 test/dummy/config/initializers/secret_token.rb
  52. +0 −8 test/dummy/config/initializers/session_store.rb
  53. +0 −16 test/dummy/config/initializers/silence_assets.rb
  54. +0 −14 test/dummy/config/initializers/wrap_parameters.rb
  55. +0 −5 test/dummy/config/locales/en.yml
  56. +0 −62 test/dummy/config/routes.rb
  57. +0 −16 test/dummy/config/unicorn.rb
  58. +0 −10 test/dummy/db/migrate/20120719231810_create_users.rb
  59. +0 −23 test/dummy/db/schema.rb
  60. 0 test/dummy/lib/assets/.gitkeep
  61. 0 test/dummy/log/.gitkeep
  62. +0 −26 test/dummy/public/404.html
  63. +0 −26 test/dummy/public/422.html
  64. +0 −25 test/dummy/public/500.html
  65. 0 test/dummy/public/favicon.ico
  66. +0 −6 test/dummy/script/rails
  67. +0 −10 test/fixtures/config/librato.yml
  68. +0 −29 test/integration/helper_test.rb
  69. +0 −15 test/integration/mail_test.rb
  70. +0 −53 test/integration/request_test.rb
  71. +0 −30 test/integration/sql_test.rb
  72. +0 −39 test/metrics-rails_test.rb
  73. +0 −105 test/remote/rails_remote_test.rb
  74. +0 −19 test/support/integration_case.rb
  75. +0 −23 test/test_helper.rb
  76. +0 −16 test/unit/aggregator_test.rb
  77. +0 −49 test/unit/configuration_test.rb
  78. +0 −19 test/unit/counter_cache_test.rb
  79. +0 −49 test/unit/group_test.rb
  80. +0 −82 test/unit/middleware_test.rb
  81. +0 −31 test/unit/worker_test.rb
View
13 Gemfile
@@ -1,13 +0,0 @@
-source "http://rubygems.org"
-gemspec
-
-# jquery-rails is used by the dummy application
-gem "jquery-rails"
-gem 'capybara'
-gem 'pry'
-#gem 'minitest'
-gem 'mocha', :require => false
-
-# servers for testing
-# gem 'thin'
-# gem 'unicorn'
View
103 README.md
@@ -1,105 +1,6 @@
-librato-rails
+metrics-rails
=======
-[![Build Status](https://secure.travis-ci.org/librato/librato-rails.png?branch=master)](http://travis-ci.org/librato/librato-rails)
-
-Report key statistics for your Rails app to [Librato Metrics](https://metrics.librato.com/), easily track your own custom metrics. Currently supports Rails 3.0+.
-
-**NOTE: This is currently in alpha development and is not yet officially supported**
-
-## Installation
-
-In your `Gemfile` add:
-
- gem 'librato-rails'
-
-Then run `bundle install`.
-
-## Configuration
-
-If you don't have a Metrics account already, [sign up](https://metrics.librato.com/). In order to send measurements to Metrics you need to provide your account credentials to `librato-rails`. You can provide these one of two ways:
-
-Create a `config/librato.yml` like the following:
-
- production:
- email: <your-email>
- api_key: <your-api-key>
-
-OR provide `LIBRATO_METRICS_USER` and `LIBRATO_METRICS_TOKEN` environment variables. If both env variables and a config file are present, environment variables will take precendence.
-
-Note that using a configuration file allows you to specify configurations per-environment. Submission will be disabled in any environment without credentials. However, if environment variables are set they will be used in all environments.
-
-Full information on configuration options is available on the [configuration wiki page](https://github.com/librato/librato-rails/wiki/Configuration).
-
-## Automatic Measurements
-
-After installing `librato-rails` and restarting your app and you will see a number of new metrics appear in your Metrics account. These track request performance, sql queries, mail handling, and other key stats. All built-in performance metrics start with the prefix `rails` by convention &mdash; for example: `rails.request.total` is the total number of requests received during an interval.
-
-If you have multiple apps reporting to the same Metrics account you can change this prefix in your [configuration](https://github.com/librato/librato-rails/wiki/Configuration).
-
-## Custom Measurements
-
-Tracking anything that interests you is easy with Metrics. There are four primary helpers available:
-
-#### increment
-
-Use for tracking a running total of something _across_ requests, examples:
-
- # increment the 'sales_completed' metric by one
- Librato.increment 'sales_completed'
-
- # increment by five
- Librato.increment 'items_purchased', 5
-
-Other things you might track this way: user signups, requests of a certain type or to a certain route, total jobs queued or processed, emails sent or received
-
-#### measure
-
-Use when you want to track an average value _per_-request. Examples:
-
- Librato.measure 'user.social_graph.nodes', 212
-
- Librato.measure 'jobs.queued', 3
-
-
-#### timing
-
-Like `Librato.measure` this is per-request, but specialized for timing information:
-
- Librato.timing 'twitter.lookup.time', 21.2
-
-The block form auto-submits the time it took for its contents to execute as the measurement value:
-
- Librato.timing 'twitter.lookup.time' do
- @twitter = Twitter.lookup(user)
- end
-
-#### group
-
-There is also a grouping helper, to make managing nested metrics easier. So this:
-
- Librato.measure 'memcached.gets', 20
- Librato.measure 'memcached.sets', 2
- Librato.measure 'memcached.hits', 18
-
-Can also be written as:
-
- Librato.group 'memcached' do |g|
- g.measure 'gets', 20
- g.measure 'sets', 2
- g.measure 'hits', 18
- end
-
-Symbols can be used interchangably with strings for metric names.
-
-## Contribution
-
-* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
-* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
-* Fork the project and submit a pull request from a feature or bugfix branch.
-* Please include tests. This is important so we don't break your changes unintentionally in a future version.
-* Please don't modify the gemspec, Rakefile, version, or changelog. If you do change these files, please isolate a separate commit so we can cherry-pick around it.
-
-## Copyright
+This project has been replaced by the newer [librato-rails](https://github.com/librato/librato-rails). Go [there](https://github.com/librato/librato-rails) now for the latest.
Copyright (c) 2012 [Librato Inc.](http://librato.com) See LICENSE for details.
View
@@ -1 +0,0 @@
-require 'librato/rails'
View
@@ -1,4 +0,0 @@
-module Librato::Rack
-end
-
-require 'librato/rack/middleware'
@@ -1,47 +0,0 @@
-class Librato::Rack::Middleware
- def initialize(app, metrics = Librato::Rails)
- @app, @metrics = app, metrics
- end
-
- def call(env)
- @metrics.check_worker if @metrics.send(:forking_server?)
-
- header_metrics env
-
- time = Time.now
- response = @app.call(env)
- duration = (Time.now - time) * 1000.0
-
- request_metrics response.first, duration
-
- response
- end
-
- private
-
- def header_metrics(env)
- return unless env.keys.include?('HTTP_X_HEROKU_QUEUE_DEPTH')
-
- @metrics.group 'rack.heroku' do |group|
- group.measure 'queue.depth', env['HTTP_X_HEROKU_QUEUE_DEPTH'].to_f
- group.timing 'queue.wait_time', env['HTTP_X_HEROKU_QUEUE_WAIT_TIME'].to_f
- group.measure 'queue.dynos', env['HTTP_X_HEROKU_DYNOS_IN_USE'].to_f
- end
- end
-
- def request_metrics(status, duration)
- @metrics.group 'rack.request' do |group|
- group.increment 'total'
- group.timing 'time', duration
- group.increment 'slow' if duration > 200.0
-
- group.group 'status' do |s|
- s.increment status
- s.increment "#{status.to_s[0]}xx"
-
- s.timing "#{status}.time", duration
- s.timing "#{status.to_s[0]}xx.time", duration
- end
- end
- end
-end
View
@@ -1,209 +0,0 @@
-require 'socket'
-require 'thread'
-
-require 'active_support/core_ext/module/attribute_accessors'
-require 'active_support/notifications'
-require 'librato/metrics'
-
-require 'librato/rack'
-require 'librato/rails/aggregator'
-require 'librato/rails/counter_cache'
-require 'librato/rails/group'
-require 'librato/rails/helpers'
-require 'librato/rails/worker'
-require 'librato/rails/version'
-
-module Librato
- extend SingleForwardable
- def_delegators Librato::Rails, :increment, :measure, :timing, :group
-
- module Rails
- extend SingleForwardable
- CONFIG_SETTABLE = %w{api_key email flush_interval prefix source}
- FORKING_SERVERS = [:unicorn, :passenger]
-
- mattr_accessor :config_file
- self.config_file = 'config/librato.yml'
-
- # config options
- mattr_accessor :api_key
- mattr_accessor :email
- mattr_accessor :flush_interval
- mattr_accessor :prefix
-
- # config defaults
- self.flush_interval = 60 # seconds
- self.prefix = 'rails'
-
- def_delegators :counters, :increment
- def_delegators :aggregate, :measure, :timing
-
- class << self
-
- # access to internal aggregator object
- def aggregate
- @aggregator_cache ||= Aggregator.new
- end
-
- # set custom api endpoint
- def api_endpoint=(endpoint)
- @api_endpoint = endpoint
- end
-
- # access to client instance
- def client
- @client ||= prepare_client
- end
-
- # detect / update configuration
- def check_config
- if self.config_file && File.exists?(self.config_file)
- configs = YAML.load_file(config_file)
- if env_specific = configs[::Rails.env]
- settable = CONFIG_SETTABLE & env_specific.keys
- settable.each { |key| self.send("#{key}=", env_specific[key]) }
- end
- end
- self.api_key = ENV['LIBRATO_METRICS_TOKEN'] if ENV['LIBRATO_METRICS_TOKEN']
- self.email = ENV['LIBRATO_METRICS_USER'] if ENV['LIBRATO_METRICS_USER']
- end
-
- # check to see if we've forked into a process where a worker
- # isn't running yet, if so start it up!
- def check_worker
- if @pid != $$
- start_worker
- #aggregate.clear
- #counters.clear
- end
- end
-
- # access to internal counters object
- def counters
- @counter_cache ||= CounterCache.new
- end
-
- # remove any accumulated but unsent metrics
- def delete_all
- aggregate.delete_all
- counters.delete_all
- end
-
- # send all current data to Metrics
- def flush
- logger.debug "[librato-rails] flushing #{Process.pid} (#{Time.now}):"
- queue = client.new_queue(:source => qualified_source)
- # thread safety is handled internally for both stores
- counters.flush_to(queue)
- aggregate.flush_to(queue)
- logger.debug queue.queued
- queue.submit unless queue.empty?
- rescue Exception => error
- logger.error "[librato-rails] submission failed permanently, worker exiting: #{error}"
- end
-
- def group(prefix)
- group = Group.new(prefix)
- yield group
- end
-
- def logger
- @logger ||= ::Rails.logger
- end
-
- # source including process pid
- def qualified_source
- "#{source}.#{$$}"
- end
-
- # run once during Rails startup sequence
- def setup
- check_config
- #return unless self.email && self.api_key
- logger.info "[librato-rails] starting up with #{app_server}..."
- @pid = $$
- if forking_server?
- install_worker_check
- else
- start_worker # start immediately
- end
- end
-
- def source
- @source ||= Socket.gethostname
- end
-
- # set a custom source
- def source=(src)
- @source = src
- end
-
- # start the worker thread, one is needed per process.
- # if this process has been forked from an one with an active
- # worker thread we don't need to worry about cleanup as only
- # the forking thread is copied.
- def start_worker
- return if @worker # already running
- @pid = $$
- logger.debug "[librato-rails] >> starting up worker for pid #{@pid}..."
- @worker = Thread.new do
- worker = Worker.new
- worker.run_periodically(self.flush_interval) do
- flush
- end
- end
- end
-
- private
-
- def app_server
- if defined?(::Unicorn) && defined?(::Unicorn::HttpServer) && !::Unicorn.listener_names.empty?
- :unicorn
- elsif defined?(::IN_PHUSION_PASSENGER) || (defined?(::Passenger) && defined?(::Passenger::AbstractServer))
- :passenger
- elsif defined?(::Thin) && defined?(::Thin::Server)
- :thin
- else
- :other
- end
- end
-
- def forking_server?
- FORKING_SERVERS.include?(app_server)
- end
-
- def install_worker_check
- ::ApplicationController.prepend_before_filter do |c|
- Librato::Rails.check_worker
- end
- end
-
- def prepare_client
- check_config
- client = Librato::Metrics::Client.new
- client.authenticate email, api_key
- client.api_endpoint = @api_endpoint if @api_endpoint
- client.custom_user_agent = user_agent
- client
- end
-
- def ruby_engine
- return RUBY_ENGINE if Object.constants.include?(:RUBY_ENGINE)
- RUBY_DESCRIPTION.split[0]
- end
-
- def user_agent
- ua_chunks = []
- ua_chunks << "librato-rails/#{Librato::Rails::VERSION}"
- ua_chunks << "(#{ruby_engine}; #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}; #{RUBY_PLATFORM}; #{app_server})"
- ua_chunks.join(' ')
- end
-
- end # end class << self
-
- end
-end
-
-# must load after all module setup
-require 'librato/rails/railtie' if defined?(Rails)
-require 'librato/rails/subscribers'
Oops, something went wrong.

0 comments on commit 98f8219

Please sign in to comment.