evenitron 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,16 @@
1
1
  # Evenitron
2
2
 
3
- Evenitron is a service to help you to properly understand the performance of your delayed_job and resque jobs.
3
+ Evenitron is a service to help you to properly understand the performance of
4
+ your delayed\_job and resque jobs.
4
5
 
5
6
  ## Getting started
6
7
 
7
- In order to use the Evenitron service you will need a `system key` which is assigned to you when you sign up for an account. This key identifies you system to the Evenitron aggregators.
8
+ In order to use the Evenitron service you will need a `system key` which is
9
+ assigned to you when you sign up for an account. This key identifies your system
10
+ to Evenitron.
8
11
 
9
- If you don't have an account you can request an invite to our private beta program here : http://evenitron.com/invite_requests/new
12
+ If you don't have an account you can
13
+ [sign up for our private beta program](http://app.evenitron.com/registrations/new).
10
14
 
11
15
  Firstly, add the gem to your Gemfile:
12
16
 
@@ -14,7 +18,8 @@ Firstly, add the gem to your Gemfile:
14
18
  gem 'evenitron'
15
19
  ```
16
20
 
17
- On start you need to configure the gem with your system key. In Rails this would go in `config\initializers\evenitron.rb`.
21
+ On start you need to configure the gem with your system key. In Rails this would
22
+ go in `config\initializers\evenitron.rb`.
18
23
 
19
24
  ```ruby
20
25
  require 'evenitron'
@@ -24,7 +29,7 @@ Evenitron.configure do |config|
24
29
  end
25
30
  ```
26
31
 
27
- Or you can rely on the environment variables `EVENITRON_SYSTEM_KEY`:
32
+ Or you can rely on the environment variable `EVENITRON_SYSTEM_KEY`:
28
33
 
29
34
  ```ruby
30
35
  require 'evenitron'
@@ -34,4 +39,18 @@ Evenitron.configure
34
39
 
35
40
  ## Notes
36
41
 
37
- You must specify your system key either through configuration or the `EVENITRON_SYSTEM_KEY` environment variable but you will normally rely on the default collector URL of `http://collector.evenitron.com/`.
42
+ You must specify your system key either through configuration or the
43
+ `EVENITRON_SYSTEM_KEY` environment variable but you will normally rely on the
44
+ default collector URL of `http://collector.evenitron.com/`.
45
+
46
+ ### Rails specific
47
+
48
+ By default, Evenitron is only enabled in production in Rails applications. If
49
+ you wish to enable it in another environment you must add this line to your
50
+ environment file:
51
+
52
+ ```ruby
53
+ config.evenitron.enabled = true
54
+ ```
55
+
56
+ Evenitron will also hook into the `Rails.logger` for all of its log messages.
@@ -1,4 +1,3 @@
1
- require 'bundler/setup'
2
1
  require 'base64'
3
2
  require 'rest_client'
4
3
  require 'securerandom'
@@ -19,16 +18,21 @@ module Evenitron
19
18
  # config.system_key = 'your system key'
20
19
  # end
21
20
  #
22
- # Raises StandardError if no system_key passed or found in env variable
23
21
  def self.configure
24
22
  yield self if block_given?
25
23
 
26
- logger.error("Evenitron system_key required") && return unless system_key
24
+ unless system_key && !system_key.empty?
25
+ logger.error "Evenitron system_key required"
26
+ Evenitron.enabled = false
27
+ logger.info "Evenitron reporting is DISABLED"
28
+ return
29
+ end
27
30
 
28
31
  initialize_delayed_job if Evenitron.delayed_job_present?
29
- initialize_resque if Evenitron.resque_present?
32
+ initialize_resque if Evenitron.resque_present?
30
33
 
31
34
  logger.info "Evenitron configured with #{system_key} #{collector_url}"
35
+ logger.info("Evenitron reporting is DISABLED") unless Evenitron.enabled
32
36
  end
33
37
 
34
38
  # Public: configured logger
@@ -53,8 +57,14 @@ module Evenitron
53
57
  # Public: Writers for the config values
54
58
  #
55
59
  attr_writer :logger, :collector_url, :system_key
60
+
61
+ attr_accessor :enabled
62
+
56
63
  end
57
64
 
65
+ # Default Evenitron to enabled.
66
+ Evenitron.enabled = true
67
+
58
68
  # Public: util method for encoding values for network transport.
59
69
  #
60
70
  # values - Enumerable of Strings
@@ -119,4 +129,7 @@ private
119
129
 
120
130
  end
121
131
 
132
+ # If we are running in a Rails environment include the Evenitron::Railtie class.
133
+ #
134
+ require_relative 'evenitron/railtie' if defined?(Rails)
122
135
 
@@ -29,20 +29,28 @@ module Evenitron
29
29
  #
30
30
  # Returns nothing
31
31
  def job_queued(args)
32
+ return unless Evenitron.enabled
33
+
32
34
  Thread.new do
33
35
  send_message :queued, args
34
36
  end
35
37
  end
36
38
 
37
39
  def job_started(args)
40
+ return unless Evenitron.enabled
41
+
38
42
  send_message :started, args
39
43
  end
40
44
 
41
45
  def job_failed(args)
46
+ return unless Evenitron.enabled
47
+
42
48
  send_message :failed, args
43
49
  end
44
50
 
45
51
  def job_complete(args)
52
+ return unless Evenitron.enabled
53
+
46
54
  send_message :complete, args
47
55
  end
48
56
 
@@ -98,4 +106,4 @@ module Evenitron
98
106
 
99
107
  end
100
108
 
101
- end
109
+ end
@@ -45,7 +45,7 @@ module Evenitron
45
45
  end
46
46
 
47
47
  end
48
-
48
+
49
49
  end
50
50
 
51
- end
51
+ end
@@ -0,0 +1,25 @@
1
+ module Evenitron
2
+
3
+ # Internal: Railtie to hook Evenitron into Rails.
4
+ #
5
+ # Hooks into the Rails.logger and disables publishing in all environments
6
+ # apart from production by default.
7
+ #
8
+ class Railtie < Rails::Railtie
9
+
10
+ # Expose Evenitron's configuration object to consumers through the Rails
11
+ # config object.
12
+ #
13
+ self.config.evenitron = Evenitron
14
+
15
+ initializer 'evenitron.initialize' do |app|
16
+ # Get Evenitron to use the Rails logger
17
+ Evenitron.logger = Rails.logger
18
+
19
+ # Only enable Evenitron in production by default
20
+ Evenitron.enabled = Rails.env.production?
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Evenitron
2
- VERSION = "0.2.2".freeze
3
- end
2
+ VERSION = "0.3.0".freeze
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evenitron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-25 00:00:00.000000000 Z
12
+ date: 2012-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &70229787376080 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 1.6.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70229787376080
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.6.7
25
30
  description: Ruby client for Evenitron with hooks for delayed_job and resque
26
31
  email:
27
32
  - support@evenitron.com
@@ -34,6 +39,7 @@ files:
34
39
  - lib/evenitron/delayed_job/collector.rb
35
40
  - lib/evenitron/delayed_job.rb
36
41
  - lib/evenitron/logger.rb
42
+ - lib/evenitron/railtie.rb
37
43
  - lib/evenitron/resque/collector.rb
38
44
  - lib/evenitron/resque/resque.rb
39
45
  - lib/evenitron/resque.rb
@@ -60,8 +66,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
66
  version: '0'
61
67
  requirements: []
62
68
  rubyforge_project: evenitron-ruby
63
- rubygems_version: 1.8.10
69
+ rubygems_version: 1.8.24
64
70
  signing_key:
65
71
  specification_version: 3
66
72
  summary: Ruby client for Evenitron
67
73
  test_files: []
74
+ has_rdoc: