instrumental_agent 0.12.3 → 0.12.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### 0.12.4 [September 19th, 2013]
2
+ * Instrumental doesn't officially support IPV6, prefer IPV4
3
+
1
4
  ### 0.12.3 [April 26th, 2013]
2
5
  * Default collector is now collector.instrumentalapp.com
3
6
 
data/README.md CHANGED
@@ -93,7 +93,7 @@ The default message sent is "USER deployed COMMIT_HASH". If you need to customiz
93
93
 
94
94
  ## Tracking metrics in Resque jobs (and Resque-like scenarios)
95
95
 
96
- If you plan on tracking metrics in Resque jobs, you will need to explicitly cleanup after the agent when the jobs are finished. You can accomplish this by adding `after_perform` and `on_failure` hooks to your Resque jobs. See the Resque [hooks documentation](https://github.com/defunkt/resque/blob/master/docs/HOOKS.md) for more information.
96
+ If you plan on tracking metrics in Resque jobs, you will need to explicitly cleanup after the agent when the jobs are finished. You can accomplish this by adding `after_perform` and `on_failure` hooks to your Resque jobs. See the Resque [hooks documentation](https://github.com/resque/resque/blob/master/docs/HOOKS.md) for more information.
97
97
 
98
98
  You're required to do this because Resque calls `exit!` when a worker has finished processing, which bypasses Ruby's `at_exit` hooks. The Instrumental Agent installs an `at_exit` hook to flush any pending metrics to the servers, but this hook is bypassed by the `exit!` call; any other code you rely that uses `exit!` should call `I.cleanup` to ensure any pending metrics are correctly sent to the server before exiting the process.
99
99
 
@@ -238,6 +238,16 @@ module Instrumental
238
238
  logger.error "Exception occurred: #{e.message}\n#{e.backtrace.join("\n")}"
239
239
  end
240
240
 
241
+ def ipv4_address_for_host(host, port)
242
+ addresses = Socket.getaddrinfo(host, port, 'AF_INET')
243
+ if (result = addresses.first)
244
+ _, _, _, address, _ = result
245
+ address
246
+ else
247
+ raise Exception.new("Couldn't get address information for host #{host}")
248
+ end
249
+ end
250
+
241
251
  def send_command(cmd, *args)
242
252
  cmd = "%s %s\n" % [cmd, args.collect { |a| a.to_s }.join(" ")]
243
253
  if enabled?
@@ -312,11 +322,16 @@ module Instrumental
312
322
  end
313
323
  end
314
324
 
325
+
326
+
315
327
  def run_worker_loop
316
328
  command_and_args = nil
317
329
  command_options = nil
318
330
  logger.info "connecting to collector"
319
- @socket = with_timeout(CONNECT_TIMEOUT) { TCPSocket.new(host, port) }
331
+ @socket = Socket.new(Socket::PF_INET, Socket::SOCK_STREAM, 0)
332
+ with_timeout(CONNECT_TIMEOUT) do
333
+ @socket.connect Socket.pack_sockaddr_in(port, ipv4_address_for_host(host, port))
334
+ end
320
335
  logger.info "connected to collector at #{host}:#{port}"
321
336
  send_with_reply_timeout "hello version #{Instrumental::VERSION} hostname #{Socket.gethostname} pid #{Process.pid}"
322
337
  send_with_reply_timeout "authenticate #{@api_key}"
@@ -1,3 +1,3 @@
1
1
  module Instrumental
2
- VERSION = '0.12.3'
2
+ VERSION = '0.12.4'
3
3
  end
data/spec/agent_spec.rb CHANGED
@@ -383,7 +383,7 @@ describe Instrumental::Agent, "connection problems" do
383
383
  it "should not wait longer than EXIT_FLUSH_TIMEOUT seconds to exit a process" do
384
384
  @server = TestServer.new
385
385
  @agent = Instrumental::Agent.new('test_token', :collector => @server.host_and_port, :synchronous => false)
386
- TCPSocket.stub!(:new) { |*args| sleep(5) && StringIO.new }
386
+ Socket.stub!(:new) { |*args| sleep(5) && StringIO.new }
387
387
  with_constants('Instrumental::Agent::EXIT_FLUSH_TIMEOUT' => 3) do
388
388
  if (pid = fork { @agent.increment('foo', 1) })
389
389
  tm = Time.now.to_f
@@ -398,7 +398,7 @@ describe Instrumental::Agent, "connection problems" do
398
398
  it "should not wait to exit a process if there are no commands queued" do
399
399
  @server = TestServer.new
400
400
  @agent = Instrumental::Agent.new('test_token', :collector => @server.host_and_port, :synchronous => false)
401
- TCPSocket.stub!(:new) { |*args| sleep(5) && StringIO.new }
401
+ Socket.stub!(:new) { |*args| sleep(5) && StringIO.new }
402
402
  with_constants('Instrumental::Agent::EXIT_FLUSH_TIMEOUT' => 3) do
403
403
  if (pid = fork { @agent.increment('foo', 1); @agent.queue.clear })
404
404
  tm = Time.now.to_f
metadata CHANGED
@@ -1,10 +1,15 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: instrumental_agent
3
- version: !ruby/object:Gem::Version
4
- version: 0.12.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 39
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 12
9
+ - 4
10
+ version: 0.12.4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Elijah Miller
9
14
  - Christopher Zelenak
10
15
  - Kristopher Chambers
@@ -12,127 +17,119 @@ authors:
12
17
  autorequire:
13
18
  bindir: bin
14
19
  cert_chain: []
15
- date: 2013-04-26 00:00:00.000000000 Z
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
18
- name: rake
19
- requirement: !ruby/object:Gem::Requirement
20
+
21
+ date: 2013-09-19 00:00:00 -04:00
22
+ default_executable:
23
+ dependencies:
24
+ - !ruby/object:Gem::Dependency
25
+ requirement: &id001 !ruby/object:Gem::Requirement
20
26
  none: false
21
- requirements:
22
- - - ! '>='
23
- - !ruby/object:Gem::Version
24
- version: '0'
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
25
34
  type: :development
35
+ name: rake
36
+ version_requirements: *id001
26
37
  prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- - !ruby/object:Gem::Dependency
34
- name: rspec
35
- requirement: !ruby/object:Gem::Requirement
38
+ - !ruby/object:Gem::Dependency
39
+ requirement: &id002 !ruby/object:Gem::Requirement
36
40
  none: false
37
- requirements:
41
+ requirements:
38
42
  - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '2.0'
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 2
47
+ - 0
48
+ version: "2.0"
41
49
  type: :development
50
+ name: rspec
51
+ version_requirements: *id002
42
52
  prerelease: false
43
- version_requirements: !ruby/object:Gem::Requirement
53
+ - !ruby/object:Gem::Dependency
54
+ requirement: &id003 !ruby/object:Gem::Requirement
44
55
  none: false
45
- requirements:
46
- - - ~>
47
- - !ruby/object:Gem::Version
48
- version: '2.0'
49
- - !ruby/object:Gem::Dependency
50
- name: fuubar
51
- requirement: !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ! '>='
55
- - !ruby/object:Gem::Version
56
- version: '0'
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
57
63
  type: :development
64
+ name: fuubar
65
+ version_requirements: *id003
58
66
  prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
62
- - - ! '>='
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
- - !ruby/object:Gem::Dependency
66
- name: guard
67
- requirement: !ruby/object:Gem::Requirement
67
+ - !ruby/object:Gem::Dependency
68
+ requirement: &id004 !ruby/object:Gem::Requirement
68
69
  none: false
69
- requirements:
70
- - - ! '>='
71
- - !ruby/object:Gem::Version
72
- version: '0'
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
73
77
  type: :development
78
+ name: guard
79
+ version_requirements: *id004
74
80
  prerelease: false
75
- version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ! '>='
79
- - !ruby/object:Gem::Version
80
- version: '0'
81
- - !ruby/object:Gem::Dependency
82
- name: guard-rspec
83
- requirement: !ruby/object:Gem::Requirement
81
+ - !ruby/object:Gem::Dependency
82
+ requirement: &id005 !ruby/object:Gem::Requirement
84
83
  none: false
85
- requirements:
86
- - - ! '>='
87
- - !ruby/object:Gem::Version
88
- version: '0'
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
89
91
  type: :development
92
+ name: guard-rspec
93
+ version_requirements: *id005
90
94
  prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: growl
99
- requirement: !ruby/object:Gem::Requirement
95
+ - !ruby/object:Gem::Dependency
96
+ requirement: &id006 !ruby/object:Gem::Requirement
100
97
  none: false
101
- requirements:
102
- - - ! '>='
103
- - !ruby/object:Gem::Version
104
- version: '0'
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
105
  type: :development
106
+ name: growl
107
+ version_requirements: *id006
106
108
  prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ! '>='
111
- - !ruby/object:Gem::Version
112
- version: '0'
113
- - !ruby/object:Gem::Dependency
114
- name: rb-fsevent
115
- requirement: !ruby/object:Gem::Requirement
109
+ - !ruby/object:Gem::Dependency
110
+ requirement: &id007 !ruby/object:Gem::Requirement
116
111
  none: false
117
- requirements:
118
- - - ! '>='
119
- - !ruby/object:Gem::Version
120
- version: '0'
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
121
119
  type: :development
120
+ name: rb-fsevent
121
+ version_requirements: *id007
122
122
  prerelease: false
123
- version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
- requirements:
126
- - - ! '>='
127
- - !ruby/object:Gem::Version
128
- version: '0'
129
123
  description: Track anything.
130
- email:
124
+ email:
131
125
  - support@instrumentalapp.com
132
126
  executables: []
127
+
133
128
  extensions: []
129
+
134
130
  extra_rdoc_files: []
135
- files:
131
+
132
+ files:
136
133
  - .gitignore
137
134
  - .rspec
138
135
  - .travis.yml
@@ -151,37 +148,41 @@ files:
151
148
  - spec/agent_spec.rb
152
149
  - spec/spec_helper.rb
153
150
  - spec/test_server.rb
151
+ has_rdoc: true
154
152
  homepage: http://github.com/fastestforward/instrumental_agent
155
153
  licenses: []
154
+
156
155
  post_install_message:
157
156
  rdoc_options: []
158
- require_paths:
157
+
158
+ require_paths:
159
159
  - lib
160
- required_ruby_version: !ruby/object:Gem::Requirement
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- segments:
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ hash: 3
166
+ segments:
167
167
  - 0
168
- hash: -1789921750295419555
169
- required_rubygems_version: !ruby/object:Gem::Requirement
168
+ version: "0"
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  none: false
171
- requirements:
172
- - - ! '>='
173
- - !ruby/object:Gem::Version
174
- version: '0'
175
- segments:
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ hash: 3
175
+ segments:
176
176
  - 0
177
- hash: -1789921750295419555
177
+ version: "0"
178
178
  requirements: []
179
+
179
180
  rubyforge_project:
180
- rubygems_version: 1.8.24
181
+ rubygems_version: 1.6.2
181
182
  signing_key:
182
183
  specification_version: 3
183
184
  summary: Agent for reporting data to instrumentalapp.com
184
- test_files:
185
+ test_files:
185
186
  - spec/agent_spec.rb
186
187
  - spec/spec_helper.rb
187
188
  - spec/test_server.rb