instana 1.9.0.sillyrabbit → 1.9.0

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0ba941e65d061723cef0a542c2f65d80d4956a9b
4
- data.tar.gz: defbff62c39a5e8dbc8e3fabceff42a43c29932e
2
+ SHA256:
3
+ metadata.gz: 19b57b244ae34d84adf8c974296e60f2030c61876a351a8f10418b06051ae7bf
4
+ data.tar.gz: 56509b6350e8de9b280747674084f510ef2b2240cedc4d7a3592504a5eb05f76
5
5
  SHA512:
6
- metadata.gz: 349ec35ff3ed2efc30fa13c9257262ae8464c1ebca45fc5398d570cb2253e185a7a17f20211720ec36e0c975ccab1f5cc1f0f5c548ee0865347c08e9f23dfee4
7
- data.tar.gz: 258a0b56f3af4d9e49f1ac53d3ba74d214ce8f9a7cfdb25cd41e1d2314177e0f65e06369ca2175dfc4e3c197da3cd06046de426c0cd4c1e9e72a2817ba3a6092
6
+ metadata.gz: 2c05dcf132296ba2d9c6ebca5769590d104c40aa678d8607ab2d381b96be78f68d85b783c8dc3ffeafce1353da8e0b74c013a997fdadedf82cc6311ca62c9e67
7
+ data.tar.gz: 7119c1e50c4f379a169dde1994e48754a5d6be3304f6cf2a8da00fd692a17eea1d1122b979e15498612eec1774104a4863cc381f6e9d274406cb61efafddf9d9
@@ -290,7 +290,7 @@ module Instana
290
290
  uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{path}")
291
291
  req = Net::HTTP::Post.new(uri)
292
292
 
293
- req.body = Oj.dump(spans)
293
+ req.body = Oj.dump(spans, :omit_nil => true)
294
294
  response = make_host_agent_request(req)
295
295
 
296
296
  if response
@@ -1,26 +1,40 @@
1
1
  require "instana/rack"
2
2
 
3
3
  if defined?(::Rails)
4
- # In Rails, let's use the Rails logger
5
- ::Instana.logger = ::Rails.logger if ::Rails.logger
6
4
 
7
5
  if ::Rails::VERSION::MAJOR < 3
8
6
  ::Rails.configuration.after_initialize do
9
- ::Instana.logger.info "Instrumenting Rack"
10
- ::Rails.configuration.middleware.insert 0, ::Instana::Rack
7
+ # In Rails, let's use the Rails logger
8
+ ::Instana.logger = ::Rails.logger if ::Rails.logger
9
+
10
+ if ::Instana.config[:tracing][:enabled]
11
+ ::Instana.logger.info "Instrumenting Rack"
12
+ ::Rails.configuration.middleware.insert 0, ::Instana::Rack
13
+ else
14
+ ::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
15
+ end
11
16
  end
12
17
  else
13
18
  module ::Instana
14
19
  class Railtie < ::Rails::Railtie
15
20
  initializer 'instana.rack' do |app|
16
- ::Instana.logger.info "Instrumenting Rack"
17
- app.config.middleware.insert 0, ::Instana::Rack
21
+ # In Rails, let's use the Rails logger
22
+ ::Instana.logger = ::Rails.logger if ::Rails.logger
23
+
24
+ if ::Instana.config[:tracing][:enabled]
25
+ ::Instana.logger.info "Instrumenting Rack"
26
+ app.config.middleware.insert 0, ::Instana::Rack
27
+ else
28
+ ::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
29
+ end
18
30
  end
19
31
 
20
- config.after_initialize do
21
- require "instana/frameworks/instrumentation/active_record"
22
- require "instana/frameworks/instrumentation/action_controller"
23
- require "instana/frameworks/instrumentation/action_view"
32
+ if ::Instana.config[:tracing][:enabled]
33
+ config.after_initialize do
34
+ require "instana/frameworks/instrumentation/active_record"
35
+ require "instana/frameworks/instrumentation/action_controller"
36
+ require "instana/frameworks/instrumentation/action_view"
37
+ end
24
38
  end
25
39
  end
26
40
  end
@@ -20,7 +20,7 @@ module Instana
20
20
  Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
21
21
  end
22
22
 
23
- kvs
23
+ { :'resque-client' => kvs }
24
24
  end
25
25
 
26
26
  def enqueue_with_instana(klass, *args)
@@ -72,12 +72,11 @@ module Instana
72
72
  begin
73
73
  kvs[:job] = job.payload['class'].to_s
74
74
  kvs[:queue] = job.queue
75
- kvs[:args] = job.payload['args'].to_json
76
75
  rescue => e
77
- Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if Instana::Config[:verbose]
76
+ ::Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if Instana::Config[:verbose]
78
77
  end
79
78
 
80
- Instana.tracer.start_or_continue_trace(:'resque-worker', nil, kvs) do
79
+ Instana.tracer.start_or_continue_trace(:'resque-worker', { :'resque-worker' => kvs }) do
81
80
  perform_without_instana(job)
82
81
  end
83
82
  end
@@ -90,8 +89,12 @@ module Instana
90
89
 
91
90
  def fail_with_instana(exception)
92
91
  if Instana.tracer.tracing?
93
- Instana.tracer.log_error(:resque, exception)
92
+ ::Instana.tracer.log_info(:'resque-worker' => { :error => "#{exception.class}: #{exception}"})
93
+ ::Instana.tracer.log_error(exception)
94
94
  end
95
+ rescue Exception => e
96
+ ::Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if Instana::Config[:verbose]
97
+ ensure
95
98
  fail_without_instana(exception)
96
99
  end
97
100
  end
@@ -1,4 +1,4 @@
1
1
  module Instana
2
- VERSION = "1.9.0.sillyrabbit"
2
+ VERSION = "1.9.0"
3
3
  VERSION_FULL = "instana-#{VERSION}"
4
4
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
- require_relative "../jobs/resque_job_1"
3
- require_relative "../jobs/resque_job_2"
2
+ require_relative "../jobs/resque_fast_job"
3
+ require_relative "../jobs/resque_error_job"
4
4
  require 'resque'
5
5
 
6
6
  if ENV.key?('REDIS_URL')
@@ -12,6 +12,9 @@ end
12
12
  class ResqueClientTest < Minitest::Test
13
13
  def setup
14
14
  clear_all!
15
+ ENV['FORK_PER_JOB'] = 'false'
16
+ Resque.redis.redis.flushall
17
+ @worker = Resque::Worker.new(:critical)
15
18
  end
16
19
 
17
20
  def teardown
@@ -19,7 +22,7 @@ class ResqueClientTest < Minitest::Test
19
22
 
20
23
  def test_enqueue
21
24
  ::Instana.tracer.start_or_continue_trace('resque-client_test') do
22
- ::Resque.enqueue(ResqueWorkerJob1)
25
+ ::Resque.enqueue(FastJob)
23
26
  end
24
27
 
25
28
  traces = Instana.processor.queued_traces
@@ -29,13 +32,18 @@ class ResqueClientTest < Minitest::Test
29
32
  assert_equal 3, spans.count
30
33
 
31
34
  assert_equal :'resque-client_test', spans[0][:data][:sdk][:name]
35
+
32
36
  assert_equal :"resque-client", spans[1][:n]
37
+ assert_equal "FastJob", spans[1][:data][:'resque-client'][:job]
38
+ assert_equal :critical, spans[1][:data][:'resque-client'][:queue]
39
+ assert_equal false, spans[1][:data][:'resque-client'].key?(:error)
40
+
33
41
  assert_equal :redis, spans[2][:n]
34
42
  end
35
43
 
36
44
  def test_enqueue_to
37
45
  ::Instana.tracer.start_or_continue_trace('resque-client_test') do
38
- ::Resque.enqueue_to(:critical, ResqueWorkerJob1)
46
+ ::Resque.enqueue_to(:critical, FastJob)
39
47
  end
40
48
 
41
49
  traces = Instana.processor.queued_traces
@@ -46,12 +54,15 @@ class ResqueClientTest < Minitest::Test
46
54
 
47
55
  assert_equal :'resque-client_test', spans[0][:data][:sdk][:name]
48
56
  assert_equal :"resque-client", spans[1][:n]
57
+ assert_equal "FastJob", spans[1][:data][:'resque-client'][:job]
58
+ assert_equal :critical, spans[1][:data][:'resque-client'][:queue]
59
+ assert_equal false, spans[1][:data][:'resque-client'].key?(:error)
49
60
  assert_equal :redis, spans[2][:n]
50
61
  end
51
62
 
52
63
  def test_dequeue
53
64
  ::Instana.tracer.start_or_continue_trace('resque-client_test', '', {}) do
54
- ::Resque.dequeue(ResqueWorkerJob2, { :generate => :farfalla })
65
+ ::Resque.dequeue(FastJob, { :generate => :farfalla })
55
66
  end
56
67
 
57
68
  traces = Instana.processor.queued_traces
@@ -62,6 +73,56 @@ class ResqueClientTest < Minitest::Test
62
73
 
63
74
  assert_equal :'resque-client_test', spans[0][:data][:sdk][:name]
64
75
  assert_equal :"resque-client", spans[1][:n]
76
+ assert_equal "FastJob", spans[1][:data][:'resque-client'][:job]
77
+ assert_equal :critical, spans[1][:data][:'resque-client'][:queue]
78
+ assert_equal false, spans[1][:data][:'resque-client'].key?(:error)
65
79
  assert_equal :redis, spans[2][:n]
66
80
  end
81
+
82
+ def test_worker_job
83
+ Resque::Job.create(:critical, FastJob)
84
+ @worker.work(0)
85
+
86
+ traces = Instana.processor.queued_traces
87
+ assert_equal 1, traces.count
88
+
89
+ spans = traces[0].spans.to_a
90
+ assert_equal 3, spans.count
91
+
92
+ resque_span = spans[0]
93
+ redis1_span = spans[1]
94
+ redis2_span = spans[2]
95
+
96
+ assert_equal :'resque-worker', resque_span[:n]
97
+ assert_equal false, resque_span.key?(:error)
98
+ assert_equal false, resque_span.key?(:ec)
99
+ assert_equal "FastJob", resque_span[:data][:'resque-worker'][:job]
100
+ assert_equal "critical", resque_span[:data][:'resque-worker'][:queue]
101
+ assert_equal false, resque_span[:data][:'resque-worker'].key?(:error)
102
+
103
+ assert_equal :redis, redis1_span[:n]
104
+ assert_equal "SET", redis1_span[:data][:redis][:command]
105
+ assert_equal :redis, redis2_span[:n]
106
+ assert_equal "SET", redis2_span[:data][:redis][:command]
107
+ end
108
+
109
+ def test_worker_error_job
110
+ Resque::Job.create(:critical, ErrorJob)
111
+ @worker.work(0)
112
+
113
+ traces = Instana.processor.queued_traces
114
+ assert_equal 1, traces.count
115
+
116
+ spans = traces[0].spans.to_a
117
+ resque_span = spans[0]
118
+ assert_equal 5, spans.count
119
+
120
+ assert_equal :'resque-worker', resque_span[:n]
121
+ assert_equal true, resque_span.key?(:error)
122
+ assert_equal 1, resque_span[:ec]
123
+ assert_equal "ErrorJob", resque_span[:data][:'resque-worker'][:job]
124
+ assert_equal "critical", resque_span[:data][:'resque-worker'][:queue]
125
+ assert_equal "Exception: Silly Rabbit, Trix are for kids.", resque_span[:data][:'resque-worker'][:error]
126
+ assert_equal Array, resque_span[:stack].class
127
+ end
67
128
  end
@@ -0,0 +1,16 @@
1
+ require "redis"
2
+ require "net/http"
3
+
4
+ class ErrorJob
5
+ @queue = :critical
6
+
7
+ def self.perform
8
+ redis = Redis.new(url: ENV['REDIS_URL'])
9
+
10
+ dt = Time.now
11
+ redis.set('ts', dt)
12
+
13
+ raise Exception.new("Silly Rabbit, Trix are for kids.")
14
+ redis.set(:nb_id, 2)
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ require "redis"
2
+ require "net/http"
3
+
4
+ class FastJob
5
+ @queue = :critical
6
+
7
+ def self.perform
8
+ redis = Redis.new(url: ENV['REDIS_URL'])
9
+
10
+ dt = Time.now
11
+ redis.set('ts', dt)
12
+ redis.set(:nb_id, 2)
13
+ end
14
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0.sillyrabbit
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2018-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -280,8 +280,8 @@ files:
280
280
  - test/instrumentation/rest-client_test.rb
281
281
  - test/instrumentation/sidekiq-client_test.rb
282
282
  - test/instrumentation/sidekiq-worker_test.rb
283
- - test/jobs/resque_job_1.rb
284
- - test/jobs/resque_job_2.rb
283
+ - test/jobs/resque_error_job.rb
284
+ - test/jobs/resque_fast_job.rb
285
285
  - test/jobs/sidekiq_job_1.rb
286
286
  - test/jobs/sidekiq_job_2.rb
287
287
  - test/models/block.rb
@@ -312,12 +312,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
312
312
  version: '2.1'
313
313
  required_rubygems_version: !ruby/object:Gem::Requirement
314
314
  requirements:
315
- - - ">"
315
+ - - ">="
316
316
  - !ruby/object:Gem::Version
317
- version: 1.3.1
317
+ version: '0'
318
318
  requirements: []
319
319
  rubyforge_project:
320
- rubygems_version: 2.6.12
320
+ rubygems_version: 2.7.6
321
321
  signing_key:
322
322
  specification_version: 4
323
323
  summary: Ruby Distributed Tracing & Metrics Sensor for Instana
@@ -351,8 +351,8 @@ test_files:
351
351
  - test/instrumentation/rest-client_test.rb
352
352
  - test/instrumentation/sidekiq-client_test.rb
353
353
  - test/instrumentation/sidekiq-worker_test.rb
354
- - test/jobs/resque_job_1.rb
355
- - test/jobs/resque_job_2.rb
354
+ - test/jobs/resque_error_job.rb
355
+ - test/jobs/resque_fast_job.rb
356
356
  - test/jobs/sidekiq_job_1.rb
357
357
  - test/jobs/sidekiq_job_2.rb
358
358
  - test/models/block.rb
@@ -1,11 +0,0 @@
1
- class ResqueWorkerJob1
2
- @queue = :normal
3
-
4
- def self.perform(*args)
5
- rc = Redis.new(url: ENV['REDIS_URL'])
6
-
7
- rc.set('hello', 'world')
8
- rc.set('hello', 'paramount')
9
- rc.set('other', 'hello')
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- class ResqueWorkerJob2
2
- @queue = :normal
3
-
4
- def self.perform(*args)
5
- raise "Fake exception"
6
- end
7
- end