appsignal 0.8.0 → 0.8.1.beta.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTA0NmQ5NjdiOGVhYjQyNGY2NTlhYzkxZmZlYzhjYzNiMTMyMWQ3ZA==
4
+ NDBhODkxNDkwODA4NjY4Yjc5Zjc0Zjk2MTJiNmEwMjU2YjYxZjZjZg==
5
5
  data.tar.gz: !binary |-
6
- OTJkNmVkODA5MGI1NjE4OTE3ZDU0NzIyOGY5YzhhZjZkNzE5NjczMQ==
6
+ NzI5ZmExYmE1NGMxM2IyZGU1YzE0YWE4NjY5MjEzMzY0NWUxNWM3NA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Y2U1NzI0NWQxMjkzNWU1N2Q4OTgwMjE3MGU5ZDIwYjA5MWUwODBjMzQyMzE2
10
- NjdlMDMzNDkyNzQzNDdlMzZiNjJmMGJiNTcxNmE0ODllMzdmMTQxZjE2ZmE1
11
- ZDEwYWJjNTkxNmVlOWEwMDExYjQ2M2FlOWU3NDFiOTc3OGJlNjE=
9
+ ODE2NGY5Zjc2Mjc0MTYzMmIwNGEyYThkNTQ5NGUxNzllYzAxOTYxMGVhMjQ5
10
+ MDg2NTdjMzFlNDk3YmQwN2ZlMzQ0NzhhNGYxYzI5MzRhZjVjZGNlNzZhZDI1
11
+ ODk1OWQ4OTUxMTAwOWRmOGIyODlmOGJlMGY3M2RhOTRiN2UxNjc=
12
12
  data.tar.gz: !binary |-
13
- MTVhMjg3NTNiZjdiYmNlMGQ5NjQ2YWY0MDAyN2ZmOTJkZDdjOGVmN2MwN2Jl
14
- YmQwYzdkOGUyZDVlNjNkODk3ZDhlNDRmMjRjOTg5ZmZjNzAwOGQ5NzI4NGQw
15
- N2U4YmU5NWY3NmZhMmM3YzIyNWQyNzM0MTQzZDEwMjVhZTJlYzI=
13
+ YjQ5NmQxOGYzZGU3MDI4MzRkNDk3NDkzOTNhZjliODMyYTQ3ZmE4NzQxZmFk
14
+ MTMxNzdkZWQ4MWM4ZDU2NWQ0M2NkZmNiYTNmNzg4MjViOWE3OWU5OWI3MDQ3
15
+ YzE1MDVhN2IyZGE2Mzk1ZDdjOTU5ODBhNGU0MzAyODg3YWMyZWU=
@@ -1,3 +1,6 @@
1
+ # 0.8.1
2
+ * Fix in monitoring of queue times
3
+
1
4
  # 0.8.0
2
5
  * Support for background processors (Delayed Job and Sidekiq)
3
6
 
@@ -6,14 +6,13 @@ if defined?(::Sidekiq)
6
6
  class SidekiqPlugin
7
7
  def call(worker, item, queue)
8
8
  Appsignal::Transaction.create(SecureRandom.uuid, ENV.to_hash)
9
-
10
9
  ActiveSupport::Notifications.instrument(
11
10
  'perform_job.sidekiq',
12
11
  :class => item['class'],
13
12
  :method => 'perform',
14
13
  :attempts => item['retry_count'],
15
14
  :queue => item['queue'],
16
- :queue_time => (Time.now.to_f - item['enqueued_at'].to_f) * 1000
15
+ :queue_start => item['enqueued_at']
17
16
  ) do
18
17
  yield
19
18
  end
@@ -22,7 +22,7 @@ module Appsignal
22
22
  end
23
23
 
24
24
  attr_reader :request_id, :events, :process_action_event, :action, :exception,
25
- :env, :fullpath, :time, :tags, :kind
25
+ :env, :fullpath, :time, :tags, :kind, :queue_start
26
26
 
27
27
  def initialize(request_id, env)
28
28
  @request_id = request_id
@@ -54,6 +54,7 @@ module Appsignal
54
54
  return unless event && event.payload
55
55
  @action = "#{event.payload[:controller]}##{event.payload[:action]}"
56
56
  @kind = 'http_request'
57
+ set_http_queue_start
57
58
  end
58
59
 
59
60
  def set_perform_job_event(event)
@@ -61,6 +62,7 @@ module Appsignal
61
62
  return unless event && event.payload
62
63
  @action = "#{event.payload[:class]}##{event.payload[:method]}"
63
64
  @kind = 'background_job'
65
+ set_background_queue_start
64
66
  end
65
67
 
66
68
  def add_event(event)
@@ -121,21 +123,18 @@ module Appsignal
121
123
  end
122
124
  end
123
125
 
124
- def queue_start
125
- if @kind == 'background_job'
126
- @process_action_event.payload[:queue_start].to_f
127
- else
128
- http_queue_start
129
- end
126
+ def set_background_queue_start
127
+ return unless process_action_event.payload[:queue_start]
128
+ @queue_start = process_action_event.payload[:queue_start].to_f
130
129
  end
131
130
 
132
- def http_queue_start
131
+ def set_http_queue_start
133
132
  return unless env
134
133
  env_var = env['HTTP_X_QUEUE_START'] || env['HTTP_X_REQUEST_START']
135
134
  if env_var
136
135
  value = env_var.tr('^0-9', '')
137
136
  unless value.empty?
138
- value.to_f / 1_000_000
137
+ @queue_start = value.to_f / 1_000_000
139
138
  end
140
139
  end
141
140
  end
@@ -49,8 +49,8 @@ module Appsignal
49
49
  end
50
50
 
51
51
  def add_queue_duration_to_hash!
52
- start = queue_start
53
- if start
52
+ start = queue_start || 0.0
53
+ if start > 0
54
54
  hash[:log_entry][:queue_duration] = hash[:log_entry][:time] - start
55
55
  end
56
56
  end
@@ -1,3 +1,3 @@
1
1
  module Appsignal
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1.beta.0'
3
3
  end
@@ -39,7 +39,7 @@ describe "Sidekiq integration" do
39
39
  :method => 'perform',
40
40
  :attempts => 0,
41
41
  :queue => 'default',
42
- :queue_time => 60_000
42
+ :queue_start => Time.parse('01-01-2001 10:00:00UTC')
43
43
  )
44
44
  end
45
45
 
@@ -32,7 +32,8 @@ describe Appsignal::Transaction do
32
32
  {
33
33
  'HTTP_USER_AGENT' => 'IE6',
34
34
  'SERVER_NAME' => 'localhost',
35
- 'action_dispatch.routes' => 'not_available'
35
+ 'action_dispatch.routes' => 'not_available',
36
+ 'HTTP_X_REQUEST_START' => '1000000'
36
37
  }
37
38
  end
38
39
  let(:transaction) { Appsignal::Transaction.create('1', env) }
@@ -45,6 +46,7 @@ describe Appsignal::Transaction do
45
46
 
46
47
  describe '#set_process_action_event' do
47
48
  before { transaction.set_process_action_event(process_action_event) }
49
+
48
50
  let(:process_action_event) { notification_event }
49
51
 
50
52
  it 'should add a process action event' do
@@ -58,14 +60,20 @@ describe Appsignal::Transaction do
58
60
  it "should set the kind" do
59
61
  transaction.kind.should == 'http_request'
60
62
  end
63
+
64
+ it "should call set_http_queue_start" do
65
+ transaction.queue_start.should_not be_nil
66
+ end
61
67
  end
62
68
 
63
69
  describe "set_perform_job_event" do
64
70
  before { transaction.set_perform_job_event(perform_job_event) }
71
+
72
+ let(:payload) { create_background_payload }
65
73
  let(:perform_job_event) do
66
74
  notification_event(
67
75
  :name => 'perform_job.delayed_job',
68
- :payload => create_background_payload
76
+ :payload => payload
69
77
  )
70
78
  end
71
79
 
@@ -80,6 +88,10 @@ describe Appsignal::Transaction do
80
88
  it "should set the kind" do
81
89
  transaction.kind.should == 'background_job'
82
90
  end
91
+
92
+ it "should set call set_background_queue_start" do
93
+ transaction.queue_start.should_not be_nil
94
+ end
83
95
  end
84
96
 
85
97
  describe "#set_tags" do
@@ -316,39 +328,46 @@ describe Appsignal::Transaction do
316
328
  end
317
329
  end
318
330
 
319
- describe "#queue_start" do
331
+ describe "#set_background_queue_start" do
332
+ before do
333
+ transaction.stub(:process_action_event =>
334
+ notification_event(
335
+ :name => 'perform_job.delayed_job',
336
+ :payload => payload
337
+ )
338
+ )
339
+ transaction.set_background_queue_start
340
+ end
320
341
  subject { transaction.queue_start }
321
342
 
322
- context "for a http request" do
323
- let(:transaction) { regular_transaction }
343
+ context "when queue start is nil" do
344
+ let(:payload) { create_background_payload(:queue_start => nil) }
324
345
 
325
- it "should call http_queue_start" do
326
- transaction.should_receive(:http_queue_start)
327
- subject
328
- end
346
+ it { should be_nil }
329
347
  end
330
348
 
331
- context "for a background job" do
332
- let(:transaction) { background_job_transaction }
349
+ context "when queue start is set" do
350
+ let(:payload) { create_background_payload }
333
351
 
334
- it "should get the queue start from the payload" do
335
- subject.should == 978364850.0
336
- end
352
+ it { should == 978364850.0 }
337
353
  end
338
354
  end
339
355
 
340
- describe "#http_queue_start" do
356
+ describe "#set_http_queue_start" do
341
357
  let(:slightly_earlier_time) { fixed_time - 10.0 }
342
358
  let(:slightly_earlier_time_in_msec) { (slightly_earlier_time.to_f * 1_000_000).to_i }
343
- subject { transaction.send(:http_queue_start) }
359
+ before { transaction.set_http_queue_start }
360
+ subject { transaction.queue_start }
344
361
 
345
- context "without the env" do
362
+ context "without env" do
346
363
  let(:env) { nil }
347
364
 
348
365
  it { should be_nil }
349
366
  end
350
367
 
351
368
  context "with no relevant header set" do
369
+ let(:env) { {} }
370
+
352
371
  it { should be_nil }
353
372
  end
354
373
 
@@ -12,7 +12,7 @@ module NotificationHelpers
12
12
  )
13
13
  end
14
14
 
15
- def create_payload(args = {})
15
+ def create_payload(args={})
16
16
  {
17
17
  :path => '/blog',
18
18
  :action => 'show',
@@ -33,6 +33,6 @@ module NotificationHelpers
33
33
  :attempts => 0,
34
34
  :queue => 'default',
35
35
  :queue_start => fixed_time - 10,
36
- }
36
+ }.merge(args)
37
37
  end
38
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1.beta.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-01-03 00:00:00.000000000 Z
15
+ date: 2014-01-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -237,9 +237,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
237
  version: 1.9.3
238
238
  required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  requirements:
240
- - - ! '>='
240
+ - - ! '>'
241
241
  - !ruby/object:Gem::Version
242
- version: '0'
242
+ version: 1.3.1
243
243
  requirements: []
244
244
  rubyforge_project:
245
245
  rubygems_version: 2.0.3