instana 1.201.0.pre1 → 1.201.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/instana/activators/active_job.rb +21 -0
- data/lib/instana/backend/host_agent_reporting_observer.rb +2 -4
- data/lib/instana/instrumentation/active_job.rb +52 -0
- data/lib/instana/tracing/span.rb +1 -1
- data/lib/instana/version.rb +1 -1
- data/test/instrumentation/rails_active_job_test.rb +65 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a12265a63ae5d07df74d4e8c1b81fe17559960726a5562c6c59b83571eb4f25
|
4
|
+
data.tar.gz: 2844f85c68a18ead499aef5ec6634d726305b824dada97d1e1e386e1c40774fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97c13b14a55c13d2e5e898711fee065699d817169cc39ab1b15c322bf075d1f4c3b715dc4fa1490f8cc7d53ef01e0ba348f7548cae400ab028c8da1fed607484
|
7
|
+
data.tar.gz: 0c4e03ef64a6273cbbf2f41bb2e57228a68b4a579298c4c26c3bd109b5002ba7e7fb1337609bc8a712e9fb7ff1902a0e46a2a0bdcd386fd13ca454172228032d
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
module Instana
|
5
|
+
module Activators
|
6
|
+
class ActiveJob < Activator
|
7
|
+
def can_instrument?
|
8
|
+
defined?(::ActiveJob::Base)
|
9
|
+
end
|
10
|
+
|
11
|
+
def instrument
|
12
|
+
require 'instana/instrumentation/active_job'
|
13
|
+
|
14
|
+
::ActiveJob::Base
|
15
|
+
.prepend(Instana::Instrumentation::ActiveJob)
|
16
|
+
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -49,11 +49,10 @@ module Instana
|
|
49
49
|
response = @client.send_request('POST', path, spans)
|
50
50
|
|
51
51
|
unless response.ok?
|
52
|
+
@logger.debug("Sent `#{spans.count}` spans to `#{path}` and got `#{response.code}`.")
|
52
53
|
@discovery.swap { nil }
|
53
54
|
break
|
54
55
|
end
|
55
|
-
|
56
|
-
@logger.debug("Sent `#{spans.count}` spans to `#{path}` and got `#{response.code}`.")
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
@@ -68,10 +67,9 @@ module Instana
|
|
68
67
|
if response.ok?
|
69
68
|
handle_agent_tasks(response, discovery) unless response.body.empty?
|
70
69
|
else
|
70
|
+
@logger.debug("Sent `#{payload}` to `#{path}` and got `#{response.code}`.")
|
71
71
|
@discovery.swap { nil }
|
72
72
|
end
|
73
|
-
|
74
|
-
@logger.debug("Sent `#{payload}` to `#{path}` and got `#{response.code}`.")
|
75
73
|
end
|
76
74
|
|
77
75
|
def handle_agent_tasks(response, discovery)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
module Instana
|
5
|
+
module Instrumentation
|
6
|
+
module ActiveJob
|
7
|
+
def self.prepended(target)
|
8
|
+
target.around_enqueue do |job, block|
|
9
|
+
tags = {
|
10
|
+
activejob: {
|
11
|
+
queue: job.queue_name,
|
12
|
+
job: job.class.to_s,
|
13
|
+
action: :enqueue,
|
14
|
+
job_id: job.job_id
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
::Instana::Tracer.trace(:activejob, tags) do
|
19
|
+
context = ::Instana.tracer.context
|
20
|
+
job.arguments = [{
|
21
|
+
given_arguments: job.arguments,
|
22
|
+
instana_context: context ? context.to_hash : nil
|
23
|
+
}]
|
24
|
+
|
25
|
+
block.call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
target.around_perform do |job, block|
|
30
|
+
tags = {
|
31
|
+
activejob: {
|
32
|
+
queue: job.queue_name,
|
33
|
+
job: job.class.to_s,
|
34
|
+
action: :perform,
|
35
|
+
job_id: job.job_id
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
incoming_context = if job.arguments.is_a?(Array) && job.arguments.first.is_a?(Hash)
|
40
|
+
instana_context = job.arguments.first[:instana_context]
|
41
|
+
job.arguments = job.arguments.first[:given_arguments]
|
42
|
+
instana_context ? ::Instana::SpanContext.new(instana_context[:trace_id], instana_context[:span_id]) : nil
|
43
|
+
end
|
44
|
+
|
45
|
+
::Instana::Tracer.start_or_continue_trace(:activejob, tags, incoming_context) do
|
46
|
+
block.call
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -6,7 +6,7 @@ module Instana
|
|
6
6
|
REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
|
7
7
|
:memcache, :'net-http', :rack, :render, :'rpc-client',
|
8
8
|
:'rpc-server', :'sidekiq-client', :'sidekiq-worker',
|
9
|
-
:redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb, :s3, :sns, :sqs, :'aws.lambda.entry' ].freeze
|
9
|
+
:redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb, :s3, :sns, :sqs, :'aws.lambda.entry', :activejob ].freeze
|
10
10
|
ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server', :sqs, :'aws.lambda.entry' ].freeze
|
11
11
|
EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client',
|
12
12
|
:'rpc-client', :'sidekiq-client', :redis, :dynamodb, :s3, :sns, :sqs ].freeze
|
data/lib/instana/version.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
require 'rails'
|
7
|
+
require 'active_job'
|
8
|
+
|
9
|
+
class RailsActiveJobTest < Minitest::Test
|
10
|
+
class SampleJob < ActiveJob::Base
|
11
|
+
queue_as :test_queue
|
12
|
+
|
13
|
+
def perform(*args); end
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@test_adapter = ActiveJob::Base.queue_adapter = ActiveJob::QueueAdapters::TestAdapter.new
|
18
|
+
ActiveJob::Base.logger = Logger.new('/dev/null')
|
19
|
+
|
20
|
+
clear_all!
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_perform_now
|
24
|
+
SampleJob.perform_now("test_perform_now")
|
25
|
+
spans = ::Instana.processor.queued_spans
|
26
|
+
|
27
|
+
server_span, *rest = spans
|
28
|
+
assert_equal [], rest
|
29
|
+
|
30
|
+
assert_equal :activejob, server_span[:n]
|
31
|
+
assert_equal 'RailsActiveJobTest::SampleJob', server_span[:data][:activejob][:job]
|
32
|
+
assert_equal :perform, server_span[:data][:activejob][:action]
|
33
|
+
assert_equal 'test_queue', server_span[:data][:activejob][:queue]
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_enqueue_perform
|
37
|
+
# ActiveJob::QueueAdapters::TestAdapter.new doesn't work for this test on any version less than 6
|
38
|
+
skip unless Rails::VERSION::MAJOR >= 6
|
39
|
+
|
40
|
+
Instana.tracer.start_or_continue_trace(:peform_test) do
|
41
|
+
SampleJob.perform_later("test_enqueue_perform")
|
42
|
+
end
|
43
|
+
|
44
|
+
job, *rest_jobs = @test_adapter.enqueued_jobs
|
45
|
+
assert_equal [], rest_jobs
|
46
|
+
|
47
|
+
ActiveJob::Base.execute(job)
|
48
|
+
|
49
|
+
spans = ::Instana.processor.queued_spans
|
50
|
+
client_span, _test_span, server_span, *rest = spans
|
51
|
+
assert_equal [], rest
|
52
|
+
|
53
|
+
assert_equal :activejob, server_span[:n]
|
54
|
+
assert_equal 'RailsActiveJobTest::SampleJob', server_span[:data][:activejob][:job]
|
55
|
+
assert_equal :perform, server_span[:data][:activejob][:action]
|
56
|
+
|
57
|
+
assert_equal :activejob, client_span[:n]
|
58
|
+
assert_equal 'RailsActiveJobTest::SampleJob', client_span[:data][:activejob][:job]
|
59
|
+
assert_equal :enqueue, client_span[:data][:activejob][:action]
|
60
|
+
assert_equal 'test_queue', server_span[:data][:activejob][:queue]
|
61
|
+
|
62
|
+
assert_equal client_span[:t], server_span[:t]
|
63
|
+
assert_equal client_span[:s], server_span[:p]
|
64
|
+
end
|
65
|
+
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.201.0
|
4
|
+
version: 1.201.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: 2021-06-
|
11
|
+
date: 2021-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- lib/instana/activators/action_controller_api.rb
|
184
184
|
- lib/instana/activators/action_controller_base.rb
|
185
185
|
- lib/instana/activators/action_view.rb
|
186
|
+
- lib/instana/activators/active_job.rb
|
186
187
|
- lib/instana/activators/active_record.rb
|
187
188
|
- lib/instana/activators/aws_sdk_dynamodb.rb
|
188
189
|
- lib/instana/activators/aws_sdk_s3.rb
|
@@ -224,6 +225,7 @@ files:
|
|
224
225
|
- lib/instana/instrumentation/action_cable.rb
|
225
226
|
- lib/instana/instrumentation/action_controller.rb
|
226
227
|
- lib/instana/instrumentation/action_view.rb
|
228
|
+
- lib/instana/instrumentation/active_job.rb
|
227
229
|
- lib/instana/instrumentation/active_record.rb
|
228
230
|
- lib/instana/instrumentation/aws_sdk_dynamodb.rb
|
229
231
|
- lib/instana/instrumentation/aws_sdk_s3.rb
|
@@ -294,6 +296,7 @@ files:
|
|
294
296
|
- test/instrumentation/rails_action_cable_test.rb
|
295
297
|
- test/instrumentation/rails_action_controller_test.rb
|
296
298
|
- test/instrumentation/rails_action_view_test.rb
|
299
|
+
- test/instrumentation/rails_active_job_test.rb
|
297
300
|
- test/instrumentation/rails_active_record_test.rb
|
298
301
|
- test/instrumentation/redis_test.rb
|
299
302
|
- test/instrumentation/resque_test.rb
|
@@ -357,9 +360,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
357
360
|
version: '2.1'
|
358
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
359
362
|
requirements:
|
360
|
-
- - "
|
363
|
+
- - ">="
|
361
364
|
- !ruby/object:Gem::Version
|
362
|
-
version:
|
365
|
+
version: '0'
|
363
366
|
requirements: []
|
364
367
|
rubygems_version: 3.1.6
|
365
368
|
signing_key:
|
@@ -394,6 +397,7 @@ test_files:
|
|
394
397
|
- test/instrumentation/rails_action_cable_test.rb
|
395
398
|
- test/instrumentation/rails_action_controller_test.rb
|
396
399
|
- test/instrumentation/rails_action_view_test.rb
|
400
|
+
- test/instrumentation/rails_active_job_test.rb
|
397
401
|
- test/instrumentation/rails_active_record_test.rb
|
398
402
|
- test/instrumentation/redis_test.rb
|
399
403
|
- test/instrumentation/resque_test.rb
|