chillout 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +45 -9
- data/CHANGELOG.md +14 -0
- data/Gemfile +8 -0
- data/README.md +43 -7
- data/Rakefile +17 -2
- data/chillout.gemspec +21 -10
- data/lib/chillout/client.rb +26 -5
- data/lib/chillout/config.rb +15 -0
- data/lib/chillout/creation_listener.rb +10 -5
- data/lib/chillout/custom_metric.rb +27 -0
- data/lib/chillout/integrations/sidekiq.rb +22 -0
- data/lib/chillout/job.rb +12 -0
- data/lib/chillout/listener_injector.rb +23 -0
- data/lib/chillout/middleware/creations_monitor.rb +1 -1
- data/lib/chillout/middleware/sidekiq.rb +21 -0
- data/lib/chillout/railtie.rb +12 -14
- data/lib/chillout/server_side/dispatcher.rb +1 -1
- data/lib/chillout/server_side/plain_http_client.rb +22 -2
- data/lib/chillout/version.rb +1 -1
- data/lib/chillout/worker.rb +5 -5
- data/lib/chillout.rb +11 -0
- data/test/acceptance/client_sends_metrics_test.rb +21 -0
- data/test/acceptance/sidekiq_workers_send_metrics_test.rb +22 -0
- data/test/config_test.rb +31 -1
- data/test/custom_metric_test.rb +15 -0
- data/test/event_data_builder_test.rb +47 -41
- data/test/integration/client_test.rb +78 -4
- data/test/integration/worker_test.rb +3 -2
- data/test/middleware/creations_monitor_test.rb +28 -29
- data/test/middleware/sidekiq_test.rb +45 -0
- data/test/plain_http_client_test.rb +13 -0
- data/test/support/rails_3_2_13/Gemfile +5 -0
- data/test/support/rails_3_2_13/Rakefile +7 -0
- data/test/support/rails_3_2_13/app/controllers/application_controller.rb +3 -0
- data/test/support/rails_3_2_13/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_3_2_13/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_3_2_13/app/models/entity.rb +3 -0
- data/test/support/rails_3_2_13/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_3_2_13/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_3_2_13/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_3_2_13/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_3_2_13/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_3_2_13/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_3_2_13/config/application.rb +63 -0
- data/test/support/rails_3_2_13/config/boot.rb +6 -0
- data/test/support/rails_3_2_13/config/database.yml +11 -0
- data/test/support/rails_3_2_13/config/environment.rb +5 -0
- data/test/support/rails_3_2_13/config/environments/development.rb +32 -0
- data/test/support/rails_3_2_13/config/environments/production.rb +56 -0
- data/test/support/rails_3_2_13/config/environments/test.rb +37 -0
- data/test/support/rails_3_2_13/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_3_2_13/config/initializers/inflections.rb +15 -0
- data/test/support/rails_3_2_13/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_3_2_13/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_3_2_13/config/initializers/secret_token.rb +7 -0
- data/test/support/rails_3_2_13/config/initializers/session_store.rb +8 -0
- data/test/support/rails_3_2_13/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_3_2_13/config/locales/en.yml +5 -0
- data/test/support/rails_3_2_13/config/routes.rb +3 -0
- data/test/support/rails_3_2_13/config.ru +4 -0
- data/test/support/rails_3_2_13/db/schema.rb +22 -0
- data/test/support/rails_3_2_13/public/404.html +26 -0
- data/test/support/rails_3_2_13/public/422.html +26 -0
- data/test/support/rails_3_2_13/public/500.html +25 -0
- data/test/support/rails_3_2_13/public/favicon.ico +0 -0
- data/test/support/rails_3_2_13/public/robots.txt +5 -0
- data/test/support/rails_3_2_13/script/rails +6 -0
- data/test/support/rails_4_0_0/Gemfile +5 -0
- data/test/support/rails_4_0_0/Rakefile +6 -0
- data/test/support/rails_4_0_0/app/controllers/application_controller.rb +5 -0
- data/test/support/rails_4_0_0/app/controllers/concerns/.keep +0 -0
- data/test/support/rails_4_0_0/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_4_0_0/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_4_0_0/app/models/.keep +0 -0
- data/test/support/rails_4_0_0/app/models/concerns/.keep +0 -0
- data/test/support/rails_4_0_0/app/models/entity.rb +2 -0
- data/test/support/rails_4_0_0/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_4_0_0/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_4_0_0/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_4_0_0/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_4_0_0/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_4_0_0/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_4_0_0/config/application.rb +31 -0
- data/test/support/rails_4_0_0/config/boot.rb +4 -0
- data/test/support/rails_4_0_0/config/database.yml +11 -0
- data/test/support/rails_4_0_0/config/environment.rb +5 -0
- data/test/support/rails_4_0_0/config/environments/development.rb +25 -0
- data/test/support/rails_4_0_0/config/environments/production.rb +67 -0
- data/test/support/rails_4_0_0/config/environments/test.rb +36 -0
- data/test/support/rails_4_0_0/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_4_0_0/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/support/rails_4_0_0/config/initializers/inflections.rb +16 -0
- data/test/support/rails_4_0_0/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_4_0_0/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_4_0_0/config/initializers/secret_token.rb +12 -0
- data/test/support/rails_4_0_0/config/initializers/session_store.rb +3 -0
- data/test/support/rails_4_0_0/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_4_0_0/config/locales/en.yml +23 -0
- data/test/support/rails_4_0_0/config/routes.rb +3 -0
- data/test/support/rails_4_0_0/config.ru +4 -0
- data/test/support/rails_4_0_0/db/schema.rb +22 -0
- data/test/support/rails_4_0_0/lib/assets/.keep +0 -0
- data/test/support/rails_4_0_0/lib/tasks/.keep +0 -0
- data/test/support/rails_4_0_0/public/404.html +58 -0
- data/test/support/rails_4_0_0/public/422.html +58 -0
- data/test/support/rails_4_0_0/public/500.html +57 -0
- data/test/support/rails_4_0_0/public/favicon.ico +0 -0
- data/test/support/rails_4_0_0/public/robots.txt +5 -0
- data/test/support/rails_4_0_0/script/bundle +3 -0
- data/test/support/rails_4_0_0/script/rails +4 -0
- data/test/support/rails_4_0_0/script/rake +4 -0
- data/test/support/rails_4_0_13/Gemfile +5 -0
- data/test/support/rails_4_0_13/Rakefile +6 -0
- data/test/support/rails_4_0_13/app/controllers/application_controller.rb +5 -0
- data/test/support/rails_4_0_13/app/controllers/concerns/.keep +0 -0
- data/test/support/rails_4_0_13/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_4_0_13/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_4_0_13/app/models/.keep +0 -0
- data/test/support/rails_4_0_13/app/models/concerns/.keep +0 -0
- data/test/support/rails_4_0_13/app/models/entity.rb +2 -0
- data/test/support/rails_4_0_13/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_4_0_13/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_4_0_13/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_4_0_13/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_4_0_13/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_4_0_13/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_4_0_13/config/application.rb +31 -0
- data/test/support/rails_4_0_13/config/boot.rb +4 -0
- data/test/support/rails_4_0_13/config/database.yml +11 -0
- data/test/support/rails_4_0_13/config/environment.rb +5 -0
- data/test/support/rails_4_0_13/config/environments/development.rb +25 -0
- data/test/support/rails_4_0_13/config/environments/production.rb +67 -0
- data/test/support/rails_4_0_13/config/environments/test.rb +36 -0
- data/test/support/rails_4_0_13/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_4_0_13/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/support/rails_4_0_13/config/initializers/inflections.rb +16 -0
- data/test/support/rails_4_0_13/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_4_0_13/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_4_0_13/config/initializers/secret_token.rb +12 -0
- data/test/support/rails_4_0_13/config/initializers/session_store.rb +3 -0
- data/test/support/rails_4_0_13/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_4_0_13/config/locales/en.yml +23 -0
- data/test/support/rails_4_0_13/config/routes.rb +3 -0
- data/test/support/rails_4_0_13/config.ru +4 -0
- data/test/support/rails_4_0_13/db/schema.rb +22 -0
- data/test/support/rails_4_0_13/lib/assets/.keep +0 -0
- data/test/support/rails_4_0_13/lib/tasks/.keep +0 -0
- data/test/support/rails_4_0_13/public/404.html +58 -0
- data/test/support/rails_4_0_13/public/422.html +58 -0
- data/test/support/rails_4_0_13/public/500.html +57 -0
- data/test/support/rails_4_0_13/public/favicon.ico +0 -0
- data/test/support/rails_4_0_13/public/robots.txt +5 -0
- data/test/support/rails_4_0_13/script/bundle +3 -0
- data/test/support/rails_4_0_13/script/rails +4 -0
- data/test/support/rails_4_0_13/script/rake +4 -0
- data/test/support/rails_4_1_0/Gemfile +5 -0
- data/test/support/rails_4_1_0/Rakefile +6 -0
- data/test/support/rails_4_1_0/app/controllers/application_controller.rb +5 -0
- data/test/support/rails_4_1_0/app/controllers/concerns/.keep +0 -0
- data/test/support/rails_4_1_0/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_4_1_0/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_4_1_0/app/models/.keep +0 -0
- data/test/support/rails_4_1_0/app/models/concerns/.keep +0 -0
- data/test/support/rails_4_1_0/app/models/entity.rb +2 -0
- data/test/support/rails_4_1_0/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_4_1_0/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_4_1_0/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_4_1_0/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_4_1_0/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_4_1_0/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_4_1_0/config/application.rb +31 -0
- data/test/support/rails_4_1_0/config/boot.rb +4 -0
- data/test/support/rails_4_1_0/config/database.yml +11 -0
- data/test/support/rails_4_1_0/config/environment.rb +5 -0
- data/test/support/rails_4_1_0/config/environments/development.rb +25 -0
- data/test/support/rails_4_1_0/config/environments/production.rb +67 -0
- data/test/support/rails_4_1_0/config/environments/test.rb +36 -0
- data/test/support/rails_4_1_0/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_4_1_0/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/support/rails_4_1_0/config/initializers/inflections.rb +16 -0
- data/test/support/rails_4_1_0/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_4_1_0/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_4_1_0/config/initializers/secret_token.rb +12 -0
- data/test/support/rails_4_1_0/config/initializers/session_store.rb +3 -0
- data/test/support/rails_4_1_0/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_4_1_0/config/locales/en.yml +23 -0
- data/test/support/rails_4_1_0/config/routes.rb +3 -0
- data/test/support/rails_4_1_0/config.ru +4 -0
- data/test/support/rails_4_1_0/db/schema.rb +22 -0
- data/test/support/rails_4_1_0/lib/assets/.keep +0 -0
- data/test/support/rails_4_1_0/lib/tasks/.keep +0 -0
- data/test/support/rails_4_1_0/public/404.html +58 -0
- data/test/support/rails_4_1_0/public/422.html +58 -0
- data/test/support/rails_4_1_0/public/500.html +57 -0
- data/test/support/rails_4_1_0/public/favicon.ico +0 -0
- data/test/support/rails_4_1_0/public/robots.txt +5 -0
- data/test/support/rails_4_1_0/script/bundle +3 -0
- data/test/support/rails_4_1_0/script/rails +4 -0
- data/test/support/rails_4_1_0/script/rake +4 -0
- data/test/support/rails_4_1_16/Gemfile +5 -0
- data/test/support/rails_4_1_16/Rakefile +6 -0
- data/test/support/rails_4_1_16/app/controllers/application_controller.rb +5 -0
- data/test/support/rails_4_1_16/app/controllers/concerns/.keep +0 -0
- data/test/support/rails_4_1_16/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_4_1_16/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_4_1_16/app/models/.keep +0 -0
- data/test/support/rails_4_1_16/app/models/concerns/.keep +0 -0
- data/test/support/rails_4_1_16/app/models/entity.rb +2 -0
- data/test/support/rails_4_1_16/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_4_1_16/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_4_1_16/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_4_1_16/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_4_1_16/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_4_1_16/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_4_1_16/config/application.rb +31 -0
- data/test/support/rails_4_1_16/config/boot.rb +4 -0
- data/test/support/rails_4_1_16/config/database.yml +11 -0
- data/test/support/rails_4_1_16/config/environment.rb +5 -0
- data/test/support/rails_4_1_16/config/environments/development.rb +25 -0
- data/test/support/rails_4_1_16/config/environments/production.rb +67 -0
- data/test/support/rails_4_1_16/config/environments/test.rb +36 -0
- data/test/support/rails_4_1_16/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_4_1_16/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/support/rails_4_1_16/config/initializers/inflections.rb +16 -0
- data/test/support/rails_4_1_16/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_4_1_16/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_4_1_16/config/initializers/secret_token.rb +12 -0
- data/test/support/rails_4_1_16/config/initializers/session_store.rb +3 -0
- data/test/support/rails_4_1_16/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_4_1_16/config/locales/en.yml +23 -0
- data/test/support/rails_4_1_16/config/routes.rb +3 -0
- data/test/support/rails_4_1_16/config.ru +4 -0
- data/test/support/rails_4_1_16/db/schema.rb +22 -0
- data/test/support/rails_4_1_16/lib/assets/.keep +0 -0
- data/test/support/rails_4_1_16/lib/tasks/.keep +0 -0
- data/test/support/rails_4_1_16/public/404.html +58 -0
- data/test/support/rails_4_1_16/public/422.html +58 -0
- data/test/support/rails_4_1_16/public/500.html +57 -0
- data/test/support/rails_4_1_16/public/favicon.ico +0 -0
- data/test/support/rails_4_1_16/public/robots.txt +5 -0
- data/test/support/rails_4_1_16/script/bundle +3 -0
- data/test/support/rails_4_1_16/script/rails +4 -0
- data/test/support/rails_4_1_16/script/rake +4 -0
- data/test/support/rails_4_2_0/Gemfile +5 -0
- data/test/support/rails_4_2_0/Rakefile +6 -0
- data/test/support/rails_4_2_0/app/controllers/application_controller.rb +5 -0
- data/test/support/rails_4_2_0/app/controllers/concerns/.keep +0 -0
- data/test/support/rails_4_2_0/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_4_2_0/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_4_2_0/app/models/.keep +0 -0
- data/test/support/rails_4_2_0/app/models/concerns/.keep +0 -0
- data/test/support/rails_4_2_0/app/models/entity.rb +2 -0
- data/test/support/rails_4_2_0/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_4_2_0/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_4_2_0/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_4_2_0/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_4_2_0/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_4_2_0/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_4_2_0/config/application.rb +31 -0
- data/test/support/rails_4_2_0/config/boot.rb +4 -0
- data/test/support/rails_4_2_0/config/database.yml +11 -0
- data/test/support/rails_4_2_0/config/environment.rb +5 -0
- data/test/support/rails_4_2_0/config/environments/development.rb +25 -0
- data/test/support/rails_4_2_0/config/environments/production.rb +67 -0
- data/test/support/rails_4_2_0/config/environments/test.rb +36 -0
- data/test/support/rails_4_2_0/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_4_2_0/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/support/rails_4_2_0/config/initializers/inflections.rb +16 -0
- data/test/support/rails_4_2_0/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_4_2_0/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_4_2_0/config/initializers/secret_token.rb +12 -0
- data/test/support/rails_4_2_0/config/initializers/session_store.rb +3 -0
- data/test/support/rails_4_2_0/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_4_2_0/config/locales/en.yml +23 -0
- data/test/support/rails_4_2_0/config/routes.rb +3 -0
- data/test/support/rails_4_2_0/config.ru +4 -0
- data/test/support/rails_4_2_0/db/schema.rb +22 -0
- data/test/support/rails_4_2_0/lib/assets/.keep +0 -0
- data/test/support/rails_4_2_0/lib/tasks/.keep +0 -0
- data/test/support/rails_4_2_0/public/404.html +58 -0
- data/test/support/rails_4_2_0/public/422.html +58 -0
- data/test/support/rails_4_2_0/public/500.html +57 -0
- data/test/support/rails_4_2_0/public/favicon.ico +0 -0
- data/test/support/rails_4_2_0/public/robots.txt +5 -0
- data/test/support/rails_4_2_0/script/bundle +3 -0
- data/test/support/rails_4_2_0/script/rails +4 -0
- data/test/support/rails_4_2_0/script/rake +4 -0
- data/test/support/rails_4_2_8/Gemfile +5 -0
- data/test/support/rails_4_2_8/Rakefile +6 -0
- data/test/support/rails_4_2_8/app/controllers/application_controller.rb +5 -0
- data/test/support/rails_4_2_8/app/controllers/concerns/.keep +0 -0
- data/test/support/rails_4_2_8/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_4_2_8/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_4_2_8/app/models/.keep +0 -0
- data/test/support/rails_4_2_8/app/models/concerns/.keep +0 -0
- data/test/support/rails_4_2_8/app/models/entity.rb +2 -0
- data/test/support/rails_4_2_8/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_4_2_8/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_4_2_8/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_4_2_8/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_4_2_8/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_4_2_8/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_4_2_8/config/application.rb +34 -0
- data/test/support/rails_4_2_8/config/boot.rb +4 -0
- data/test/support/rails_4_2_8/config/database.yml +11 -0
- data/test/support/rails_4_2_8/config/environment.rb +5 -0
- data/test/support/rails_4_2_8/config/environments/development.rb +25 -0
- data/test/support/rails_4_2_8/config/environments/production.rb +73 -0
- data/test/support/rails_4_2_8/config/environments/test.rb +36 -0
- data/test/support/rails_4_2_8/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_4_2_8/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/support/rails_4_2_8/config/initializers/inflections.rb +16 -0
- data/test/support/rails_4_2_8/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_4_2_8/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_4_2_8/config/initializers/secret_token.rb +12 -0
- data/test/support/rails_4_2_8/config/initializers/session_store.rb +3 -0
- data/test/support/rails_4_2_8/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_4_2_8/config/locales/en.yml +23 -0
- data/test/support/rails_4_2_8/config/routes.rb +3 -0
- data/test/support/rails_4_2_8/config.ru +4 -0
- data/test/support/rails_4_2_8/db/schema.rb +22 -0
- data/test/support/rails_4_2_8/lib/assets/.keep +0 -0
- data/test/support/rails_4_2_8/lib/tasks/.keep +0 -0
- data/test/support/rails_4_2_8/public/404.html +58 -0
- data/test/support/rails_4_2_8/public/422.html +58 -0
- data/test/support/rails_4_2_8/public/500.html +57 -0
- data/test/support/rails_4_2_8/public/favicon.ico +0 -0
- data/test/support/rails_4_2_8/public/robots.txt +5 -0
- data/test/support/rails_4_2_8/script/bundle +3 -0
- data/test/support/rails_4_2_8/script/rails +4 -0
- data/test/support/rails_4_2_8/script/rake +4 -0
- data/test/support/rails_5_0_3/Gemfile +5 -0
- data/test/support/rails_5_0_3/Rakefile +6 -0
- data/test/support/rails_5_0_3/app/controllers/application_controller.rb +5 -0
- data/test/support/rails_5_0_3/app/controllers/concerns/.keep +0 -0
- data/test/support/rails_5_0_3/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_5_0_3/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_5_0_3/app/models/.keep +0 -0
- data/test/support/rails_5_0_3/app/models/concerns/.keep +0 -0
- data/test/support/rails_5_0_3/app/models/entity.rb +2 -0
- data/test/support/rails_5_0_3/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_5_0_3/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_5_0_3/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_5_0_3/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_5_0_3/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_5_0_3/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_5_0_3/config/application.rb +30 -0
- data/test/support/rails_5_0_3/config/boot.rb +4 -0
- data/test/support/rails_5_0_3/config/database.yml +11 -0
- data/test/support/rails_5_0_3/config/environment.rb +5 -0
- data/test/support/rails_5_0_3/config/environments/development.rb +25 -0
- data/test/support/rails_5_0_3/config/environments/production.rb +73 -0
- data/test/support/rails_5_0_3/config/environments/test.rb +36 -0
- data/test/support/rails_5_0_3/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_5_0_3/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/support/rails_5_0_3/config/initializers/inflections.rb +16 -0
- data/test/support/rails_5_0_3/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_5_0_3/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_5_0_3/config/initializers/secret_token.rb +12 -0
- data/test/support/rails_5_0_3/config/initializers/session_store.rb +3 -0
- data/test/support/rails_5_0_3/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_5_0_3/config/locales/en.yml +23 -0
- data/test/support/rails_5_0_3/config/routes.rb +3 -0
- data/test/support/rails_5_0_3/config.ru +4 -0
- data/test/support/rails_5_0_3/db/schema.rb +22 -0
- data/test/support/rails_5_0_3/lib/assets/.keep +0 -0
- data/test/support/rails_5_0_3/lib/tasks/.keep +0 -0
- data/test/support/rails_5_0_3/public/404.html +58 -0
- data/test/support/rails_5_0_3/public/422.html +58 -0
- data/test/support/rails_5_0_3/public/500.html +57 -0
- data/test/support/rails_5_0_3/public/favicon.ico +0 -0
- data/test/support/rails_5_0_3/public/robots.txt +5 -0
- data/test/support/rails_5_0_3/script/bundle +3 -0
- data/test/support/rails_5_0_3/script/rails +4 -0
- data/test/support/rails_5_0_3/script/rake +4 -0
- data/test/support/rails_5_1_1/Gemfile +6 -0
- data/test/support/rails_5_1_1/Rakefile +6 -0
- data/test/support/rails_5_1_1/app/controllers/application_controller.rb +5 -0
- data/test/support/rails_5_1_1/app/controllers/concerns/.keep +0 -0
- data/test/support/rails_5_1_1/app/controllers/entities_controller.rb +70 -0
- data/test/support/rails_5_1_1/app/helpers/application_helper.rb +2 -0
- data/test/support/rails_5_1_1/app/jobs/create_entity_job.rb +6 -0
- data/test/support/rails_5_1_1/app/models/.keep +0 -0
- data/test/support/rails_5_1_1/app/models/concerns/.keep +0 -0
- data/test/support/rails_5_1_1/app/models/entity.rb +2 -0
- data/test/support/rails_5_1_1/app/views/entities/_form.html.erb +21 -0
- data/test/support/rails_5_1_1/app/views/entities/edit.html.erb +6 -0
- data/test/support/rails_5_1_1/app/views/entities/index.html.erb +23 -0
- data/test/support/rails_5_1_1/app/views/entities/new.html.erb +5 -0
- data/test/support/rails_5_1_1/app/views/entities/show.html.erb +10 -0
- data/test/support/rails_5_1_1/app/views/layouts/application.html.erb +14 -0
- data/test/support/rails_5_1_1/config/application.rb +30 -0
- data/test/support/rails_5_1_1/config/boot.rb +4 -0
- data/test/support/rails_5_1_1/config/database.yml +11 -0
- data/test/support/rails_5_1_1/config/environment.rb +5 -0
- data/test/support/rails_5_1_1/config/environments/development.rb +25 -0
- data/test/support/rails_5_1_1/config/environments/production.rb +73 -0
- data/test/support/rails_5_1_1/config/environments/test.rb +36 -0
- data/test/support/rails_5_1_1/config/initializers/backtrace_silencers.rb +7 -0
- data/test/support/rails_5_1_1/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/support/rails_5_1_1/config/initializers/inflections.rb +16 -0
- data/test/support/rails_5_1_1/config/initializers/load_schema.rb +4 -0
- data/test/support/rails_5_1_1/config/initializers/mime_types.rb +5 -0
- data/test/support/rails_5_1_1/config/initializers/secret_token.rb +12 -0
- data/test/support/rails_5_1_1/config/initializers/session_store.rb +3 -0
- data/test/support/rails_5_1_1/config/initializers/wrap_parameters.rb +14 -0
- data/test/support/rails_5_1_1/config/locales/en.yml +23 -0
- data/test/support/rails_5_1_1/config/routes.rb +3 -0
- data/test/support/rails_5_1_1/config.ru +4 -0
- data/test/support/rails_5_1_1/db/schema.rb +22 -0
- data/test/support/rails_5_1_1/lib/assets/.keep +0 -0
- data/test/support/rails_5_1_1/lib/tasks/.keep +0 -0
- data/test/support/rails_5_1_1/public/404.html +58 -0
- data/test/support/rails_5_1_1/public/422.html +58 -0
- data/test/support/rails_5_1_1/public/500.html +57 -0
- data/test/support/rails_5_1_1/public/favicon.ico +0 -0
- data/test/support/rails_5_1_1/public/robots.txt +5 -0
- data/test/support/rails_5_1_1/script/bundle +3 -0
- data/test/support/rails_5_1_1/script/rails +4 -0
- data/test/support/rails_5_1_1/script/rake +4 -0
- data/test/test_helper.rb +149 -11
- data/test/worker_test.rb +1 -1
- metadata +974 -143
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 197e690562925f6ce9309e2545460a42280ca5d9
|
4
|
+
data.tar.gz: d130742ff61be6f59e38a2f389bc424f66feeeac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1929db6e6dcc8816f58cd33760443bda3b3c201f10f207808ceb26cc4307919e67c73d7cb3d1852e05eae6f41366563f1fdaf3f3b0db568c3fc6e409e9b3630a
|
7
|
+
data.tar.gz: ca1ba2c6c1e335394f303e506636a8d2bfb0126e81b366145eec930780746ad464fe3fbc67491197267e79b0d61952cafeb7ece3bbfd3c1dd94562d5949b8d5a
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,11 +1,47 @@
|
|
1
|
+
before_script: bundle exec rake bundle
|
2
|
+
script: bundle exec rake test
|
1
3
|
language: ruby
|
2
4
|
rvm:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
- 2.4.1
|
6
|
+
- 2.3.4
|
7
|
+
- 2.2.7
|
8
|
+
- 2.1.10
|
9
|
+
env:
|
10
|
+
- SAMPLE_APP=rails_4_0_0
|
11
|
+
- SAMPLE_APP=rails_4_0_13
|
12
|
+
- SAMPLE_APP=rails_4_1_0
|
13
|
+
- SAMPLE_APP=rails_4_1_16
|
14
|
+
- SAMPLE_APP=rails_4_2_0
|
15
|
+
- SAMPLE_APP=rails_4_2_8
|
16
|
+
- SAMPLE_APP=rails_5_0_3
|
17
|
+
- SAMPLE_APP=rails_5_1_1 SIDEKIQ_SUPPORTED=true
|
18
|
+
matrix:
|
19
|
+
exclude:
|
20
|
+
- rvm: 2.4.1
|
21
|
+
env: SAMPLE_APP=rails_4_0_0
|
22
|
+
- rvm: 2.4.1
|
23
|
+
env: SAMPLE_APP=rails_4_0_13
|
24
|
+
- rvm: 2.4.1
|
25
|
+
env: SAMPLE_APP=rails_4_1_0
|
26
|
+
- rvm: 2.4.1
|
27
|
+
env: SAMPLE_APP=rails_4_1_16
|
28
|
+
- rvm: 2.4.1
|
29
|
+
env: SAMPLE_APP=rails_4_2_0
|
30
|
+
- rvm: 2.1.10
|
31
|
+
env: SAMPLE_APP=rails_4_2_8
|
32
|
+
- rvm: 2.1.10
|
33
|
+
env: SAMPLE_APP=rails_5_0_3
|
34
|
+
- rvm: 2.1.10
|
35
|
+
env: SAMPLE_APP=rails_5_1_1 SIDEKIQ_SUPPORTED=true
|
36
|
+
include:
|
37
|
+
- rvm: 2.4.1
|
38
|
+
env: SAMPLE_APP=rails_4_2_8 STRATEGY=active_job
|
39
|
+
- rvm: 2.4.1
|
40
|
+
env: SAMPLE_APP=rails_5_0_3 STRATEGY=active_job
|
41
|
+
- rvm: 2.4.1
|
42
|
+
env: SAMPLE_APP=rails_5_1_1 STRATEGY=active_job SIDEKIQ_SUPPORTED=true
|
43
|
+
notifications:
|
44
|
+
slack:
|
45
|
+
secure: 6IAlvKplFv94Vaf0LES197FFIgt5cs1fUFA9820mmeoTGLDQcN+4Hpv+2/NRRqrfb2k+V+uFKmsuY8azHBoKHLIzH6d1T0NS82j54Ti+tm0iFZaKLHVp8TxuIge0/e0Niamod5mMziLTg6KcM+zNBYcoxS3th1mQNWQ2mtD9JZ8=
|
46
|
+
services:
|
47
|
+
- redis-server
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# chillout gem changes
|
2
|
+
|
3
|
+
0.8.0
|
4
|
+
-----
|
5
|
+
|
6
|
+
- Introduce `active_job` strategy for sending metrics to chillout servers
|
7
|
+
- Add `sidekiq` integration. Metrics collected when processing sidekiq jobs are sent to the server
|
8
|
+
- Support for Mongoid removed.
|
9
|
+
|
10
|
+
0.7.0 (never released)
|
11
|
+
----------------------
|
12
|
+
|
13
|
+
- Support for custom metrics
|
14
|
+
- Support for Mongoid
|
data/Gemfile
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
gem "bbq-spawn", git: 'https://github.com/drugpl/bbq-spawn.git'
|
4
|
+
|
3
5
|
# Specify your gem's dependencies in chillout.gemspec
|
4
6
|
gemspec
|
7
|
+
|
8
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2')
|
9
|
+
gem "rack", "1.6"
|
10
|
+
gem "activejob", "= 4.2.8"
|
11
|
+
gem "sidekiq", "~> 4.2"
|
12
|
+
end
|
data/README.md
CHANGED
@@ -4,9 +4,11 @@
|
|
4
4
|
[![Code Climate](https://codeclimate.com/github/chilloutio/chillout.png)](https://codeclimate.com/github/chilloutio/chillout)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/chillout.png)](http://badge.fury.io/rb/chillout)
|
6
6
|
|
7
|
+
Chillout gem tracks your ActiveRecord models statistics. You can see the metrics for your application in a grafana dashboard. Please visit [get.chillout.io](http://get.chillout.io/) for more details.
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
|
-
Add this line to your Rails application's Gemfile
|
11
|
+
Add this line to your Rails application's `Gemfile`:
|
10
12
|
|
11
13
|
gem 'chillout'
|
12
14
|
|
@@ -14,14 +16,48 @@ And then execute:
|
|
14
16
|
|
15
17
|
$ bundle
|
16
18
|
|
17
|
-
And
|
19
|
+
And add following line to `config/environments/production.rb` with your own `SECRET_KEY`:
|
20
|
+
|
21
|
+
config.chillout = { secret: 'SECRET_KEY' }
|
22
|
+
|
23
|
+
And that's all!
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
chillout gem is automatically tracking your model creations. Remember you have to be in `production` environment - otherwise chillout gem will NOT track your metrics.
|
28
|
+
|
29
|
+
### Custom metrics
|
30
|
+
|
31
|
+
You can use `Chillout::Metric.track('custom_name')` to track a custom, phony metric. It's quite useful when you want to track a certain business process, like:
|
32
|
+
|
33
|
+
```
|
34
|
+
# in 'new':
|
35
|
+
Chillout::Metric.track('RegistrationStarted')
|
36
|
+
|
37
|
+
# in 'create':
|
38
|
+
Chillout::Metric.track('RegistrationCompleted')
|
39
|
+
```
|
40
|
+
|
41
|
+
We encourage you to ship your own class (Adapter) which encapsulates this global constant and it's closer to your application's domain.
|
42
|
+
|
43
|
+
## Different strategy
|
44
|
+
|
45
|
+
By default chillout uses a background thread to send metrics in a non-blocking way. However, if you prefer it can use `active_job` and the adapter you configured for it ie. sidekiq, resque, delayed_job, etc.
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
config.chillout = {secret: 'secret', strategy: :active_job}
|
49
|
+
```
|
50
|
+
|
51
|
+
This feature is available since Rails 4.2
|
18
52
|
|
19
|
-
|
53
|
+
## Compatibility
|
20
54
|
|
21
|
-
|
55
|
+
Chillout gem is tested using Travis CI. You can [check it](https://travis-ci.org/chilloutio/chillout) to get insight about which versions of Rails and Rubies are actually supported. We provide listeners for ActiveRecord.
|
22
56
|
|
23
|
-
|
57
|
+
## Development
|
24
58
|
|
25
|
-
|
59
|
+
Running complete test suite:
|
26
60
|
|
27
|
-
|
61
|
+
bundle install
|
62
|
+
bundle exec rake bundle
|
63
|
+
bundle exec rake test
|
data/Rakefile
CHANGED
@@ -1,10 +1,25 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
|
-
task :default => :test
|
5
4
|
|
6
|
-
|
5
|
+
SAMPLE_APPS = Dir.glob(File.join(File.dirname(__FILE__), 'test/support/rails_*'))
|
6
|
+
|
7
|
+
desc 'Install test dependencies.'
|
8
|
+
task :bundle do
|
9
|
+
sample_apps = if sample_app = ENV['SAMPLE_APP']
|
10
|
+
[ File.join(File.dirname(__FILE__), "test/support/#{sample_app}") ]
|
11
|
+
else
|
12
|
+
SAMPLE_APPS
|
13
|
+
end
|
14
|
+
sample_apps.each do |path|
|
15
|
+
Bundler.clean_system "bundle install --quiet --gemfile #{File.join(path, 'Gemfile')}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Run chillout tests.'
|
7
20
|
Rake::TestTask.new(:test) do |t|
|
8
21
|
t.libs = %w(lib test)
|
9
22
|
t.pattern = 'test/**/*_test.rb'
|
10
23
|
end
|
24
|
+
|
25
|
+
task :default => :test
|
data/chillout.gemspec
CHANGED
@@ -6,11 +6,17 @@ require 'chillout/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "chillout"
|
8
8
|
gem.version = Chillout::VERSION
|
9
|
-
gem.authors = ["Michał Łomnicki", "Jan Filipowski", "Paweł Pacana"]
|
10
|
-
gem.email = [
|
11
|
-
|
9
|
+
gem.authors = ["Michał Łomnicki", "Jan Filipowski", "Paweł Pacana", "Robert Pankowecki"]
|
10
|
+
gem.email = [
|
11
|
+
"michal.lomnicki@gmail.com",
|
12
|
+
"jachuf@gmail.com",
|
13
|
+
"pawel.pacana@gmail.com",
|
14
|
+
"dev@arkency.com",
|
15
|
+
"robert.pankowecki@gmail.com"
|
16
|
+
]
|
17
|
+
gem.description = "Chillout gem tracks your ActiveRecord models statistics."
|
12
18
|
gem.summary = "Chillout.io Ruby client"
|
13
|
-
gem.homepage = "http://chillout.io/"
|
19
|
+
gem.homepage = "http://get.chillout.io/"
|
14
20
|
|
15
21
|
gem.files = `git ls-files`.split($/)
|
16
22
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -19,10 +25,15 @@ Gem::Specification.new do |gem|
|
|
19
25
|
|
20
26
|
gem.add_dependency 'multi_json', '~> 1.4'
|
21
27
|
|
22
|
-
gem.add_development_dependency "
|
23
|
-
gem.add_development_dependency "
|
24
|
-
gem.add_development_dependency "mocha",
|
25
|
-
gem.add_development_dependency "
|
26
|
-
gem.add_development_dependency "rack
|
27
|
-
gem.add_development_dependency "webmock",
|
28
|
+
gem.add_development_dependency "rake"
|
29
|
+
gem.add_development_dependency "minitest", "~> 5.1"
|
30
|
+
gem.add_development_dependency "mocha", "~> 0.14"
|
31
|
+
gem.add_development_dependency "rack-test", "~> 0.6"
|
32
|
+
gem.add_development_dependency "rack", ">= 1.6"
|
33
|
+
gem.add_development_dependency "webmock", "~> 2.3"
|
34
|
+
gem.add_development_dependency "bbq-spawn", "= 0.0.3"
|
35
|
+
gem.add_development_dependency "childprocess", "= 0.3.6"
|
36
|
+
gem.add_development_dependency "minitest-stub-const", "~> 0.6"
|
37
|
+
gem.add_development_dependency "activejob", ">= 4.2"
|
38
|
+
gem.add_development_dependency "sidekiq"
|
28
39
|
end
|
data/lib/chillout/client.rb
CHANGED
@@ -30,14 +30,35 @@ module Chillout
|
|
30
30
|
@event_data_builder = EventDataBuilder.new(@config).freeze
|
31
31
|
@server_side = ServerSide.new(@event_data_builder, @http_client).freeze
|
32
32
|
@dispatcher = Dispatcher.new(@server_side).freeze
|
33
|
-
@
|
34
|
-
|
33
|
+
case @config.strategy
|
34
|
+
when :thread
|
35
|
+
@queue = Queue.new
|
36
|
+
@worker_mutex = Mutex.new
|
37
|
+
@worker_thread = nil
|
38
|
+
when :active_job
|
39
|
+
require 'chillout/job'
|
40
|
+
Chillout::Job.dispatcher = @dispatcher
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def start
|
45
|
+
case @config.strategy
|
46
|
+
when :thread
|
47
|
+
start_worker
|
48
|
+
when :active_job
|
49
|
+
end
|
35
50
|
end
|
36
51
|
|
37
52
|
def enqueue(creations)
|
38
|
-
|
39
|
-
|
40
|
-
|
53
|
+
case @config.strategy
|
54
|
+
when :thread
|
55
|
+
start_worker
|
56
|
+
@logger.debug "Creations were enqueued."
|
57
|
+
@queue << creations
|
58
|
+
when :active_job
|
59
|
+
@logger.debug "Creations were enqueued."
|
60
|
+
Chillout::Job.perform_later(YAML.dump(creations))
|
61
|
+
end
|
41
62
|
end
|
42
63
|
|
43
64
|
def worker_running?
|
data/lib/chillout/config.rb
CHANGED
@@ -22,6 +22,7 @@ module Chillout
|
|
22
22
|
attr_writer :authentication_password
|
23
23
|
attr_accessor :logger
|
24
24
|
attr_accessor :ssl
|
25
|
+
attr_reader :strategy
|
25
26
|
|
26
27
|
def initialize(api_key = nil)
|
27
28
|
@api_key = api_key
|
@@ -32,6 +33,10 @@ module Chillout
|
|
32
33
|
@version = VERSION
|
33
34
|
@logger = Logger.new(STDOUT)
|
34
35
|
@ssl = true
|
36
|
+
@strategy = :thread
|
37
|
+
|
38
|
+
@authentication_user = nil
|
39
|
+
@authentication_password = nil
|
35
40
|
end
|
36
41
|
|
37
42
|
def update(options)
|
@@ -40,6 +45,16 @@ module Chillout
|
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
48
|
+
def strategy=(name)
|
49
|
+
name = name.to_sym
|
50
|
+
precondition = {
|
51
|
+
active_job: -> { defined?(ActiveJob) or raise ArgumentError, "ActiveJob is not enabled" },
|
52
|
+
thread: -> {},
|
53
|
+
}.fetch(name, -> { raise ArgumentError, "unknown strategy" })
|
54
|
+
precondition.call
|
55
|
+
@strategy = name
|
56
|
+
end
|
57
|
+
|
43
58
|
def authentication_user
|
44
59
|
@authentication_user || api_key
|
45
60
|
end
|
@@ -1,16 +1,21 @@
|
|
1
1
|
require 'chillout/creations_container'
|
2
2
|
|
3
3
|
module Chillout
|
4
|
-
module
|
4
|
+
module ActiveRecordCreationListener
|
5
5
|
def inherited(subclass)
|
6
6
|
super
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
listen(subclass)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
def listen(monitored_class)
|
12
|
+
class_name = monitored_class.name
|
13
|
+
monitored_class.after_commit :on => :create do
|
14
|
+
Rails.logger.debug "[Chillout] Model created: #{class_name}"
|
10
15
|
Thread.current[:creations] ||= CreationsContainer.new
|
11
16
|
creations = Thread.current[:creations]
|
12
17
|
creations.increment!(class_name)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
16
|
-
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'chillout/creations_container'
|
2
|
+
|
3
|
+
module Chillout
|
4
|
+
class CustomMetric
|
5
|
+
def initialize(creations_container = nil)
|
6
|
+
@creations_container = creations_container
|
7
|
+
end
|
8
|
+
|
9
|
+
def track(name)
|
10
|
+
creations_container.increment!(name)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def creations_container
|
15
|
+
if container_not_initialized?
|
16
|
+
Thread.current[:creations] ||= CreationsContainer.new
|
17
|
+
@creations_container = Thread.current[:creations]
|
18
|
+
else
|
19
|
+
@creations_container
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def container_not_initialized?
|
24
|
+
@creations_container.nil?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Chillout
|
2
|
+
module Integrations
|
3
|
+
|
4
|
+
class Sidekiq
|
5
|
+
def available?
|
6
|
+
defined?(::Sidekiq) && ::Sidekiq.server?
|
7
|
+
end
|
8
|
+
|
9
|
+
def enable(client, a_module = ::Sidekiq)
|
10
|
+
require 'chillout/middleware/sidekiq'
|
11
|
+
@module = a_module
|
12
|
+
@module.server_middleware.add Middleware::SidekiqCreationsMonitor,
|
13
|
+
client: client
|
14
|
+
end
|
15
|
+
|
16
|
+
def disable
|
17
|
+
@module.server_middleware.clear
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/chillout/job.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Chillout
|
2
|
+
class ListenerInjector
|
3
|
+
attr_accessor :logger
|
4
|
+
|
5
|
+
LISTENERS = [:active_record]
|
6
|
+
|
7
|
+
def inject!
|
8
|
+
LISTENERS.each do |listener|
|
9
|
+
listener_injection = send("#{listener}_injector")
|
10
|
+
logger.info "[Chillout] Injected #{listener} listener" if listener_injection == true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def active_record_injector
|
15
|
+
if defined?(ActiveRecord)
|
16
|
+
ActiveRecord::Base.extend(ActiveRecordCreationListener)
|
17
|
+
return true
|
18
|
+
end
|
19
|
+
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -15,7 +15,7 @@ module Chillout
|
|
15
15
|
return status, headers, body
|
16
16
|
ensure
|
17
17
|
if Thread.current[:creations]
|
18
|
-
@client.logger.
|
18
|
+
@client.logger.debug "Non-empty creations container found"
|
19
19
|
@client.enqueue(Thread.current[:creations])
|
20
20
|
Thread.current[:creations] = nil
|
21
21
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Chillout
|
2
|
+
module Middleware
|
3
|
+
|
4
|
+
class SidekiqCreationsMonitor
|
5
|
+
def initialize(options)
|
6
|
+
@client = options.fetch(:client)
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(_worker, _job, _queue)
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
if Chillout.creations
|
13
|
+
creations = Chillout.creations
|
14
|
+
Chillout.creations = nil
|
15
|
+
@client.enqueue(creations)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/chillout/railtie.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require 'chillout/creation_listener'
|
2
|
+
require 'chillout/listener_injector'
|
2
3
|
|
3
4
|
module Chillout
|
4
5
|
class Railtie < Rails::Railtie
|
5
6
|
config.chillout = ActiveSupport::OrderedOptions.new
|
6
7
|
initializer "chillout.creations_listener_initialization" do |rails_app|
|
7
8
|
chillout_config = rails_app.config.chillout
|
8
|
-
if
|
9
|
+
if chillout_config.present?
|
9
10
|
RailsInitializer.new(rails_app, chillout_config, Rails.logger).start
|
11
|
+
else
|
12
|
+
Rails.logger.debug "[Chillout] Not enabled for #{Rails.env}"
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
@@ -27,26 +30,21 @@ module Chillout
|
|
27
30
|
@rails_logger = rails_logger
|
28
31
|
end
|
29
32
|
|
30
|
-
def start
|
33
|
+
def start(listeners_injector = ListenerInjector.new)
|
34
|
+
listeners_injector.logger = @rails_logger
|
35
|
+
|
31
36
|
@rails_logger.info "[Chillout] Railtie initializing"
|
32
37
|
client = Client.new(@chillout_config[:secret], options)
|
33
|
-
|
34
|
-
@rails_logger.info "[Chillout] Creation listener attached"
|
38
|
+
listeners_injector.inject!
|
35
39
|
@rails_app.middleware.use Middleware::CreationsMonitor, client
|
36
40
|
@rails_logger.info "[Chillout] Creation monitor enabled"
|
37
|
-
|
41
|
+
sidekiq = Integrations::Sidekiq.new
|
42
|
+
sidekiq.enable(client) if sidekiq.available?
|
43
|
+
client.start
|
38
44
|
end
|
39
45
|
|
40
46
|
def options
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
def options_list
|
45
|
-
existing_option_keys.map{|key| [key, @chillout_config[key]]}
|
46
|
-
end
|
47
|
-
|
48
|
-
def existing_option_keys
|
49
|
-
[:port, :hostname, :ssl].select{|key| @chillout_config.has_key?(key)}
|
47
|
+
{logger: @rails_logger}.merge(@chillout_config).except(:secret)
|
50
48
|
end
|
51
49
|
|
52
50
|
end
|
@@ -22,12 +22,32 @@ module Chillout
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
attr_reader :host, :port, :ssl
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@host = if ENV['CHILLOUT_CLIENT_HOST']
|
29
|
+
ENV['CHILLOUT_CLIENT_HOST']
|
30
|
+
else
|
31
|
+
"api.chillout.io"
|
32
|
+
end
|
33
|
+
@port = if ENV['CHILLOUT_CLIENT_PORT']
|
34
|
+
ENV['CHILLOUT_CLIENT_PORT'].to_i
|
35
|
+
else
|
36
|
+
443
|
37
|
+
end
|
38
|
+
@ssl = if ENV['CHILLOUT_CLIENT_SSL']
|
39
|
+
ENV['CHILLOUT_CLIENT_SSL'] == 'true'
|
40
|
+
else
|
41
|
+
true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
25
45
|
MEDIA_TYPE = "application/vnd.chillout.v1+json"
|
26
46
|
|
27
47
|
def post(path, data)
|
28
48
|
begin
|
29
|
-
http = Net::HTTP.new(
|
30
|
-
http.use_ssl =
|
49
|
+
http = Net::HTTP.new(host, port)
|
50
|
+
http.use_ssl = ssl
|
31
51
|
request_spec = Net::HTTP::Post.new(path)
|
32
52
|
request_spec.body = MultiJson.dump(data)
|
33
53
|
request_spec.content_type = MEDIA_TYPE
|
data/lib/chillout/version.rb
CHANGED
data/lib/chillout/worker.rb
CHANGED
@@ -10,9 +10,9 @@ module Chillout
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_all_containers_to_process
|
13
|
-
logger.
|
13
|
+
logger.debug "Waiting for at least one container."
|
14
14
|
all_containers = [queue.pop]
|
15
|
-
logger.
|
15
|
+
logger.debug "Received at least one container."
|
16
16
|
loop do
|
17
17
|
begin
|
18
18
|
all_containers << queue.pop(true)
|
@@ -20,7 +20,7 @@ module Chillout
|
|
20
20
|
break
|
21
21
|
end
|
22
22
|
end
|
23
|
-
logger.
|
23
|
+
logger.debug "Received containers to process: #{all_containers.count}"
|
24
24
|
all_containers
|
25
25
|
end
|
26
26
|
|
@@ -33,7 +33,7 @@ module Chillout
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def send_creations(creations_container)
|
36
|
-
logger.
|
36
|
+
logger.debug "Trying to send creations"
|
37
37
|
dispatcher.send_creations(creations_container)
|
38
38
|
logger.info "Metrics sent"
|
39
39
|
rescue Dispatcher::SendCreationsFailed
|
@@ -43,7 +43,7 @@ module Chillout
|
|
43
43
|
|
44
44
|
def send_startup_message
|
45
45
|
dispatcher.send_startup_message
|
46
|
-
logger.
|
46
|
+
logger.debug "Sending startup message"
|
47
47
|
end
|
48
48
|
|
49
49
|
def run
|
data/lib/chillout.rb
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
require "chillout/version"
|
2
2
|
require "chillout/config"
|
3
3
|
require "chillout/middleware/creations_monitor"
|
4
|
+
require "chillout/integrations/sidekiq"
|
4
5
|
require "chillout/server_side/dispatcher"
|
5
6
|
require "chillout/server_side/server_side"
|
6
7
|
require "chillout/server_side/http_client"
|
8
|
+
require "chillout/custom_metric"
|
7
9
|
require "chillout/client"
|
8
10
|
|
9
11
|
module Chillout
|
12
|
+
Metric = CustomMetric.new
|
13
|
+
|
14
|
+
def self.creations
|
15
|
+
Thread.current[:creations]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.creations=(val)
|
19
|
+
Thread.current[:creations] = val
|
20
|
+
end
|
10
21
|
end
|
11
22
|
|
12
23
|
require 'chillout/railtie' if defined?(Rails)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ClientSendsMetricsTest < AcceptanceTestCase
|
4
|
+
|
5
|
+
def test_client_sends_metrics
|
6
|
+
test_app = TestApp.new
|
7
|
+
test_endpoint = TestEndpoint.new
|
8
|
+
test_user = TestUser.new
|
9
|
+
|
10
|
+
test_endpoint.listen
|
11
|
+
test_app.boot
|
12
|
+
if ENV['STRATEGY'] != 'active_job'
|
13
|
+
assert test_endpoint.has_received_information_about_startup
|
14
|
+
end
|
15
|
+
test_user.create_entity('Myrmecophagidae')
|
16
|
+
assert test_endpoint.has_one_creation_for_entity_resource
|
17
|
+
ensure
|
18
|
+
test_app.shutdown if test_app
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|