evenitron 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ Evenitron is a service to help you to properly understand the performance of you
6
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
8
 
9
- If you don't have an account you can request an invite to our private beta program here : http://app.evenitron.com/invite_requests/new
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
10
10
 
11
11
  Firstly, add the gem to your Gemfile:
12
12
 
@@ -16,42 +16,22 @@ gem 'evenitron'
16
16
 
17
17
  On start you need to configure the gem with your system key. In Rails this would go in `config\initializers\evenitron.rb`.
18
18
 
19
- ### delayed_job setup
20
-
21
- ```ruby
22
- require 'evenitron/delayed_job'
23
-
24
- Evenitron::DelayedJob.configure do
25
- system_key 'your_key'
26
- end
27
- ```
28
-
29
- Or you can rely on the environment variables `EVENITRON_SYSTEM_KEY` and `EVENITRON_COLLECTOR_URL`:
30
-
31
- ```ruby
32
- require 'evenitron/delayed_job'
33
-
34
- Evenitron::DelayedJob.configure
35
- ```
36
-
37
- ### resque setup
38
-
39
19
  ```ruby
40
- require 'evenitron/resque'
20
+ require 'evenitron'
41
21
 
42
- Evenitron::Resque.configure do
43
- system_key 'your_key'
22
+ Evenitron.configure do |config|
23
+ config.system_key = 'your_key'
44
24
  end
45
25
  ```
46
26
 
47
- Or you can rely on the environment variables `EVENITRON_SYSTEM_KEY` and `EVENITRON_COLLECTOR_URL`:
27
+ Or you can rely on the environment variables `EVENITRON_SYSTEM_KEY`:
48
28
 
49
29
  ```ruby
50
- require 'evenitron/resque'
30
+ require 'evenitron'
51
31
 
52
- Evenitron::Resque.configure
32
+ Evenitron.configure
53
33
  ```
54
34
 
55
35
  ## Notes
56
36
 
57
- 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 `https://collector.evenitron.com/`.
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/`.
@@ -6,6 +6,7 @@ require 'logger'
6
6
  require 'json'
7
7
 
8
8
  module Evenitron
9
+ require 'evenitron/version'
9
10
  require 'evenitron/logger'
10
11
  require 'evenitron/collector_client'
11
12
  require 'evenitron/collector'
@@ -22,12 +23,12 @@ module Evenitron
22
23
  def self.configure
23
24
  yield self if block_given?
24
25
 
25
- logger.error "Evenitron system_key required" && return unless self.system_key
26
+ logger.error("Evenitron system_key required") && return unless system_key
26
27
 
27
28
  initialize_delayed_job if Evenitron.delayed_job_present?
28
29
  initialize_resque if Evenitron.resque_present?
29
30
 
30
- logger.info "Evenitron configured with #{self.system_key} #{self.collector_url}"
31
+ logger.info "Evenitron configured with #{system_key} #{collector_url}"
31
32
  end
32
33
 
33
34
  # Public: configured logger
@@ -16,14 +16,22 @@ module Evenitron
16
16
  # Returns a new instance of CollectorClient
17
17
  def initialize(system_key, url, component = nil)
18
18
  @system_key, @url = system_key, url
19
- @user_agent = 'evenitron-ruby 0.1'
19
+ @user_agent = "evenitron-ruby #{Evenitron::VERSION}"
20
20
  @user_agent = "#{@user_agent} (#{component})" if component
21
21
  @simulate_requests = ENV['EVENITRON_SIMULATE_REQUESTS'] == 'true'
22
22
  log.warn 'Simulating Evenitron messages' if @simulate_requests
23
23
  end
24
24
 
25
+ # Public: sends a job queued message. Does this within a thread
26
+ # to provide responsiveness to client process
27
+ #
28
+ # args - Hash of args
29
+ #
30
+ # Returns nothing
25
31
  def job_queued(args)
26
- send_message :queued, args
32
+ Thread.new do
33
+ send_message :queued, args
34
+ end
27
35
  end
28
36
 
29
37
  def job_started(args)
@@ -38,7 +46,7 @@ module Evenitron
38
46
  send_message :complete, args
39
47
  end
40
48
 
41
- private
49
+ private
42
50
 
43
51
  def send_message(stage, args)
44
52
  send message(stage, args)
@@ -59,13 +67,11 @@ module Evenitron
59
67
  log.debug "Sending message for #{@system_key} to #{@url} - #{json}"
60
68
  end
61
69
 
62
- Thread.new do
63
- begin
64
- RestClient.post @url, json, :content_type => nil, 'Evenitron-Key' => @system_key, 'User-Agent' => @user_agent
65
- rescue => e
66
- log.error "Failed to send message for #{@system_key} to #{@url} - #{json}"
67
- log.debug e
68
- end
70
+ begin
71
+ RestClient.post @url, json, :content_type => nil, 'Evenitron-Key' => @system_key, 'User-Agent' => @user_agent
72
+ rescue => e
73
+ log.error "Failed to send message for #{@system_key} to #{@url} - #{json}"
74
+ log.debug e
69
75
  end
70
76
 
71
77
  nil
@@ -0,0 +1,3 @@
1
+ module Evenitron
2
+ VERSION = "0.2.1".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.0
4
+ version: 0.2.1
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-17 00:00:00.000000000Z
12
+ date: 2012-06-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &70299044095340 !ruby/object:Gem::Requirement
16
+ requirement: &70185009782560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.6.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70299044095340
24
+ version_requirements: *70185009782560
25
25
  description: Ruby client for Evenitron with hooks for delayed_job and resque
26
26
  email:
27
27
  - support@evenitron.com
@@ -37,6 +37,7 @@ files:
37
37
  - lib/evenitron/resque/collector.rb
38
38
  - lib/evenitron/resque/resque.rb
39
39
  - lib/evenitron/resque.rb
40
+ - lib/evenitron/version.rb
40
41
  - lib/evenitron.rb
41
42
  - README.markdown
42
43
  homepage: https://github.com/evenitron/evenitron-ruby