instana 1.199.5 → 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/.circleci/config.yml +27 -1
- data/.rubocop.yml +11 -2
- data/lib/instana.rb +2 -4
- data/lib/instana/activator.rb +11 -1
- data/lib/instana/activators/active_job.rb +21 -0
- data/lib/instana/activators/aws_sdk_dynamodb.rb +1 -1
- data/lib/instana/activators/aws_sdk_s3.rb +1 -1
- data/lib/instana/activators/aws_sdk_sns.rb +1 -1
- data/lib/instana/activators/aws_sdk_sqs.rb +1 -1
- data/lib/instana/activators/redis.rb +1 -1
- data/lib/instana/activators/resque_worker.rb +4 -2
- data/lib/instana/activators/sidekiq_client.rb +1 -1
- data/lib/instana/activators/sidekiq_worker.rb +1 -1
- data/lib/instana/backend/host_agent.rb +7 -6
- data/lib/instana/backend/host_agent_reporting_observer.rb +2 -4
- data/lib/instana/backend/serverless_agent.rb +1 -1
- data/lib/instana/config.rb +3 -1
- data/lib/instana/frameworks/roda.rb +1 -1
- data/lib/instana/instrumentation/active_job.rb +52 -0
- data/lib/instana/instrumentation/aws_sdk_s3.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_sns.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_sqs.rb +1 -1
- data/lib/instana/instrumentation/instrumented_request.rb +4 -4
- data/lib/instana/instrumentation/rack.rb +1 -1
- data/lib/instana/instrumentation/shoryuken.rb +1 -1
- data/lib/instana/setup.rb +3 -1
- data/lib/instana/snapshot/docker_container.rb +1 -1
- data/lib/instana/snapshot/fargate_task.rb +1 -1
- data/lib/instana/snapshot/google_cloud_run_instance.rb +1 -1
- data/lib/instana/tracing/processor.rb +8 -5
- data/lib/instana/tracing/span.rb +1 -1
- data/lib/instana/tracing/span_context.rb +1 -1
- data/lib/instana/version.rb +1 -1
- data/test/instrumentation/rails_active_job_test.rb +65 -0
- metadata +63 -67
- data/benchmarks/10k-rack-traces.rb +0 -95
- data/benchmarks/Gemfile +0 -11
- data/benchmarks/Gemfile.lock +0 -38
- data/benchmarks/id_generation.rb +0 -16
- data/benchmarks/opentracing.rb +0 -30
- data/benchmarks/rack_vanilla_vs_traced.rb +0 -88
- data/benchmarks/stackprof_rack_tracing.rb +0 -80
- data/benchmarks/time_processing.rb +0 -16
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
|
data/.circleci/config.yml
CHANGED
|
@@ -155,7 +155,19 @@ commands:
|
|
|
155
155
|
name: Run Tests
|
|
156
156
|
command: |
|
|
157
157
|
bundle exec rubocop
|
|
158
|
-
|
|
158
|
+
publish_gem:
|
|
159
|
+
steps:
|
|
160
|
+
- run:
|
|
161
|
+
name: Setup Access
|
|
162
|
+
command: |
|
|
163
|
+
mkdir -p ~/.gem
|
|
164
|
+
echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
|
|
165
|
+
chmod 0600 /home/circleci/.gem/credentials
|
|
166
|
+
- run:
|
|
167
|
+
name: Publish Gem
|
|
168
|
+
command: |
|
|
169
|
+
bundle exec rake release[origin]
|
|
170
|
+
|
|
159
171
|
jobs:
|
|
160
172
|
test_core:
|
|
161
173
|
parameters:
|
|
@@ -189,8 +201,22 @@ jobs:
|
|
|
189
201
|
- checkout
|
|
190
202
|
- setup
|
|
191
203
|
- run_rubocop
|
|
204
|
+
publish:
|
|
205
|
+
executor: ruby_27
|
|
206
|
+
steps:
|
|
207
|
+
- checkout
|
|
208
|
+
- setup
|
|
209
|
+
- publish_gem
|
|
192
210
|
|
|
193
211
|
workflows:
|
|
212
|
+
publish:
|
|
213
|
+
jobs:
|
|
214
|
+
- publish:
|
|
215
|
+
filters:
|
|
216
|
+
branches:
|
|
217
|
+
ignore: /.*/
|
|
218
|
+
tags:
|
|
219
|
+
only: /^v.*/
|
|
194
220
|
core:
|
|
195
221
|
jobs:
|
|
196
222
|
- lint
|
data/.rubocop.yml
CHANGED
|
@@ -2,11 +2,14 @@ inherit_from: .rubocop_todo.yml
|
|
|
2
2
|
|
|
3
3
|
require:
|
|
4
4
|
- ./extras/license_header.rb
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
# Remove when we remove .rubocop_todo.yml
|
|
7
7
|
AllCops:
|
|
8
8
|
NewCops: disable
|
|
9
9
|
|
|
10
|
+
Metrics/PerceivedComplexity:
|
|
11
|
+
Max: 20
|
|
12
|
+
|
|
10
13
|
# Broken on 1.9
|
|
11
14
|
Style/HashSyntax:
|
|
12
15
|
Enabled: false
|
|
@@ -19,7 +22,13 @@ Style/NilComparison:
|
|
|
19
22
|
|
|
20
23
|
Style/SoleNestedConditional:
|
|
21
24
|
Enabled: false
|
|
22
|
-
|
|
25
|
+
|
|
23
26
|
# Ruby 2.1 compatibility
|
|
24
27
|
Style/SafeNavigation:
|
|
25
28
|
Enabled: false
|
|
29
|
+
|
|
30
|
+
Style/SymbolProc:
|
|
31
|
+
Enabled: false
|
|
32
|
+
|
|
33
|
+
Style/MultilineBlockChain:
|
|
34
|
+
Enabled: false
|
data/lib/instana.rb
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
# (c) Copyright IBM Corp. 2021
|
|
2
2
|
# (c) Copyright Instana Inc. 2016
|
|
3
3
|
|
|
4
|
-
require '
|
|
5
|
-
require 'sys-proctable'
|
|
6
|
-
|
|
7
|
-
require "instana/setup"
|
|
4
|
+
require 'instana/setup'
|
|
8
5
|
|
|
9
6
|
# Boot the instana agent background thread. If you wish to have greater
|
|
10
7
|
# control on the where and which thread this is run in, instead use
|
|
@@ -15,4 +12,5 @@ require "instana/setup"
|
|
|
15
12
|
# the thread of your choice.
|
|
16
13
|
#
|
|
17
14
|
|
|
15
|
+
::Instana::Activator.start
|
|
18
16
|
::Instana.agent.spawn_background_thread
|
data/lib/instana/activator.rb
CHANGED
|
@@ -43,4 +43,14 @@ module Instana
|
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
Dir["#{__dir__}/activators/*.rb"]
|
|
46
|
+
Dir["#{__dir__}/activators/*.rb"]
|
|
47
|
+
.sort
|
|
48
|
+
.select do |f|
|
|
49
|
+
if ENV['INSTANA_ACTIVATE_SET']
|
|
50
|
+
base = File.basename(f, '.rb')
|
|
51
|
+
ENV.fetch('INSTANA_ACTIVATE_SET', '').split(',').include?(base)
|
|
52
|
+
else
|
|
53
|
+
true
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
.each { |f| require(f) }
|
|
@@ -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
|
|
@@ -16,8 +16,10 @@ module Instana
|
|
|
16
16
|
::Resque::Worker.prepend(::Instana::Instrumentation::ResqueWorker)
|
|
17
17
|
::Resque::Job.prepend(::Instana::Instrumentation::ResqueJob)
|
|
18
18
|
|
|
19
|
-
::
|
|
20
|
-
::
|
|
19
|
+
if ::Instana.config[:'resque-worker'][:'setup-fork']
|
|
20
|
+
::Resque.after_fork do |_job|
|
|
21
|
+
::Instana.agent.after_fork
|
|
22
|
+
end
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
# Set this so we assure that any remaining collected traces are reported at_exit
|
|
@@ -5,7 +5,7 @@ module Instana
|
|
|
5
5
|
module Activators
|
|
6
6
|
class SidekiqClient < Activator
|
|
7
7
|
def can_instrument?
|
|
8
|
-
defined?(::Sidekiq) && ::Instana.config[:'sidekiq-client'][:enabled]
|
|
8
|
+
defined?(::Sidekiq) && ::Sidekiq.respond_to?(:configure_client) && ::Instana.config[:'sidekiq-client'][:enabled]
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def instrument
|
|
@@ -5,7 +5,7 @@ module Instana
|
|
|
5
5
|
module Activators
|
|
6
6
|
class SidekiqWorker < Activator
|
|
7
7
|
def can_instrument?
|
|
8
|
-
defined?(::Sidekiq) && ::Instana.config[:'sidekiq-worker'][:enabled]
|
|
8
|
+
defined?(::Sidekiq) && ::Sidekiq.respond_to?(:configure_server) && ::Instana.config[:'sidekiq-worker'][:enabled]
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def instrument
|
|
@@ -5,12 +5,13 @@ module Instana
|
|
|
5
5
|
module Backend
|
|
6
6
|
# @since 1.197.0
|
|
7
7
|
class HostAgent
|
|
8
|
-
attr_reader :future
|
|
8
|
+
attr_reader :future, :client
|
|
9
9
|
|
|
10
10
|
def initialize(discovery: Concurrent::Atom.new(nil), logger: ::Instana.logger)
|
|
11
11
|
@discovery = discovery
|
|
12
12
|
@logger = logger
|
|
13
13
|
@future = nil
|
|
14
|
+
@client = nil
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
def setup; end
|
|
@@ -26,14 +27,14 @@ module Instana
|
|
|
26
27
|
alias start spawn_background_thread
|
|
27
28
|
|
|
28
29
|
def announce
|
|
29
|
-
client = until_not_nil { HostAgentLookup.new.call }
|
|
30
|
+
@client = until_not_nil { HostAgentLookup.new.call }
|
|
30
31
|
@discovery.delete_observers
|
|
31
32
|
@discovery
|
|
32
|
-
.with_observer(HostAgentActivationObserver.new(client, @discovery))
|
|
33
|
-
.with_observer(HostAgentReportingObserver.new(client, @discovery))
|
|
33
|
+
.with_observer(HostAgentActivationObserver.new(@client, @discovery))
|
|
34
|
+
.with_observer(HostAgentReportingObserver.new(@client, @discovery))
|
|
34
35
|
|
|
35
36
|
@discovery.swap { nil }
|
|
36
|
-
client
|
|
37
|
+
@client
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
alias after_fork announce
|
|
@@ -48,7 +49,7 @@ module Instana
|
|
|
48
49
|
{
|
|
49
50
|
e: discovery_value['pid'],
|
|
50
51
|
h: discovery_value['agentUuid']
|
|
51
|
-
}.
|
|
52
|
+
}.reject { |_, v| v.nil? }
|
|
52
53
|
end
|
|
53
54
|
|
|
54
55
|
# @return [Array] extra headers to include in the trace
|
|
@@ -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)
|
data/lib/instana/config.rb
CHANGED
|
@@ -53,6 +53,8 @@ module Instana
|
|
|
53
53
|
# W3 Trace Context Support
|
|
54
54
|
@config[:w3_trace_correlation] = ENV['INSTANA_DISABLE_W3C_TRACE_CORRELATION'].nil?
|
|
55
55
|
|
|
56
|
+
@config[:post_fork_proc] = proc { ::Instana.agent.spawn_background_thread }
|
|
57
|
+
|
|
56
58
|
@config[:action_controller] = { :enabled => true }
|
|
57
59
|
@config[:action_view] = { :enabled => true }
|
|
58
60
|
@config[:active_record] = { :enabled => true }
|
|
@@ -63,7 +65,7 @@ module Instana
|
|
|
63
65
|
@config[:nethttp] = { :enabled => true }
|
|
64
66
|
@config[:redis] = { :enabled => true }
|
|
65
67
|
@config[:'resque-client'] = { :enabled => true }
|
|
66
|
-
@config[:'resque-worker'] = { :enabled => true }
|
|
68
|
+
@config[:'resque-worker'] = { :enabled => true, :'setup-fork' => true }
|
|
67
69
|
@config[:'rest-client'] = { :enabled => true }
|
|
68
70
|
@config[:'sidekiq-client'] = { :enabled => true }
|
|
69
71
|
@config[:'sidekiq-worker'] = { :enabled => true }
|
|
@@ -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
|
|
@@ -10,7 +10,7 @@ module Instana
|
|
|
10
10
|
op: format_operation(context.operation_name),
|
|
11
11
|
bucket: bucket_name_from(context),
|
|
12
12
|
key: key_from_context(context)
|
|
13
|
-
}.
|
|
13
|
+
}.reject { |_, v| v.nil? }
|
|
14
14
|
|
|
15
15
|
::Instana.tracer.trace(:s3, {s3: s3_tags}) { @handler.call(context) }
|
|
16
16
|
end
|
|
@@ -11,7 +11,7 @@ module Instana
|
|
|
11
11
|
target: context.params[:target_arn],
|
|
12
12
|
phone: context.params[:phone_number],
|
|
13
13
|
subject: context.params[:subject]
|
|
14
|
-
}.
|
|
14
|
+
}.reject { |_, v| v.nil? }
|
|
15
15
|
|
|
16
16
|
if context.operation_name == :publish
|
|
17
17
|
::Instana.tracer.trace(:sns, {sns: sns_tags}) { @handler.call(context) }
|
|
@@ -13,7 +13,7 @@ module Instana
|
|
|
13
13
|
return @handler.call(context)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
span_tags = tags_for(context.operation_name, context.params).
|
|
16
|
+
span_tags = tags_for(context.operation_name, context.params).reject { |_, v| v.nil? }
|
|
17
17
|
|
|
18
18
|
::Instana.tracer.trace(:sqs, {sqs: span_tags}) do |span|
|
|
19
19
|
case context.operation_name
|
|
@@ -74,7 +74,7 @@ module Instana
|
|
|
74
74
|
host: host_with_port,
|
|
75
75
|
header: extra_header_tags,
|
|
76
76
|
params: request_params
|
|
77
|
-
}.
|
|
77
|
+
}.reject { |_, v| v.nil? }
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def correlation_data
|
|
@@ -123,7 +123,7 @@ module Instana
|
|
|
123
123
|
external_trace_id: external_trace_id,
|
|
124
124
|
external_state: @env['HTTP_TRACESTATE'],
|
|
125
125
|
from_w3: false
|
|
126
|
-
}.
|
|
126
|
+
}.reject { |_, v| v.nil? }
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
def context_from_trace_parent
|
|
@@ -150,7 +150,7 @@ module Instana
|
|
|
150
150
|
trace_id: state[:t],
|
|
151
151
|
span_id: state[:p],
|
|
152
152
|
from_w3: false
|
|
153
|
-
}.
|
|
153
|
+
}.reject { |_, v| v.nil? }
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
def parse_trace_state
|
|
@@ -179,7 +179,7 @@ module Instana
|
|
|
179
179
|
{
|
|
180
180
|
type: data['correlationType'],
|
|
181
181
|
id: data['correlationId']
|
|
182
|
-
}.
|
|
182
|
+
}.reject { |_, v| v.nil? }
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
end
|
data/lib/instana/setup.rb
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# (c) Copyright IBM Corp. 2021
|
|
2
2
|
# (c) Copyright Instana Inc. 2016
|
|
3
3
|
|
|
4
|
+
require 'concurrent'
|
|
5
|
+
require 'sys-proctable'
|
|
6
|
+
|
|
4
7
|
require 'instana/logger_delegator'
|
|
5
8
|
|
|
6
9
|
require "instana/base"
|
|
@@ -37,7 +40,6 @@ require 'instana/backend/agent'
|
|
|
37
40
|
|
|
38
41
|
::Instana.setup
|
|
39
42
|
::Instana.agent.setup
|
|
40
|
-
::Instana::Activator.start
|
|
41
43
|
|
|
42
44
|
# Require supported OpenTracing interfaces
|
|
43
45
|
require "opentracing"
|
|
@@ -5,6 +5,9 @@ require 'thread'
|
|
|
5
5
|
|
|
6
6
|
module Instana
|
|
7
7
|
class Processor
|
|
8
|
+
extend Forwardable
|
|
9
|
+
def_delegators :@queue, :empty?
|
|
10
|
+
|
|
8
11
|
def initialize(logger: ::Instana.logger)
|
|
9
12
|
# The main queue before being reported to the
|
|
10
13
|
# host agent. Spans in this queue are complete
|
|
@@ -15,7 +18,7 @@ module Instana
|
|
|
15
18
|
# agent at once.
|
|
16
19
|
@batch_size = 3000
|
|
17
20
|
@logger = logger
|
|
18
|
-
@pid =
|
|
21
|
+
@pid = Process.pid
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
# Adds a span to the span queue
|
|
@@ -23,10 +26,10 @@ module Instana
|
|
|
23
26
|
# @param [Trace] - the trace to be added to the queue
|
|
24
27
|
def add_span(span)
|
|
25
28
|
# :nocov:
|
|
26
|
-
if @pid !=
|
|
27
|
-
@logger.info("Proces `#{@pid}` has forked into #{
|
|
28
|
-
::Instana.
|
|
29
|
-
@pid =
|
|
29
|
+
if @pid != Process.pid
|
|
30
|
+
@logger.info("Proces `#{@pid}` has forked into #{Process.pid}. Running post fork hook.")
|
|
31
|
+
::Instana.config[:post_fork_proc].call
|
|
32
|
+
@pid = Process.pid
|
|
30
33
|
end
|
|
31
34
|
# :nocov:
|
|
32
35
|
|
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.
|
|
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-
|
|
11
|
+
date: 2021-06-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -143,14 +143,6 @@ files:
|
|
|
143
143
|
- LICENSE
|
|
144
144
|
- README.md
|
|
145
145
|
- Rakefile
|
|
146
|
-
- benchmarks/10k-rack-traces.rb
|
|
147
|
-
- benchmarks/Gemfile
|
|
148
|
-
- benchmarks/Gemfile.lock
|
|
149
|
-
- benchmarks/id_generation.rb
|
|
150
|
-
- benchmarks/opentracing.rb
|
|
151
|
-
- benchmarks/rack_vanilla_vs_traced.rb
|
|
152
|
-
- benchmarks/stackprof_rack_tracing.rb
|
|
153
|
-
- benchmarks/time_processing.rb
|
|
154
146
|
- bin/console
|
|
155
147
|
- bin/setup
|
|
156
148
|
- docker-compose.yml
|
|
@@ -191,6 +183,7 @@ files:
|
|
|
191
183
|
- lib/instana/activators/action_controller_api.rb
|
|
192
184
|
- lib/instana/activators/action_controller_base.rb
|
|
193
185
|
- lib/instana/activators/action_view.rb
|
|
186
|
+
- lib/instana/activators/active_job.rb
|
|
194
187
|
- lib/instana/activators/active_record.rb
|
|
195
188
|
- lib/instana/activators/aws_sdk_dynamodb.rb
|
|
196
189
|
- lib/instana/activators/aws_sdk_s3.rb
|
|
@@ -232,6 +225,7 @@ files:
|
|
|
232
225
|
- lib/instana/instrumentation/action_cable.rb
|
|
233
226
|
- lib/instana/instrumentation/action_controller.rb
|
|
234
227
|
- lib/instana/instrumentation/action_view.rb
|
|
228
|
+
- lib/instana/instrumentation/active_job.rb
|
|
235
229
|
- lib/instana/instrumentation/active_record.rb
|
|
236
230
|
- lib/instana/instrumentation/aws_sdk_dynamodb.rb
|
|
237
231
|
- lib/instana/instrumentation/aws_sdk_s3.rb
|
|
@@ -302,6 +296,7 @@ files:
|
|
|
302
296
|
- test/instrumentation/rails_action_cable_test.rb
|
|
303
297
|
- test/instrumentation/rails_action_controller_test.rb
|
|
304
298
|
- test/instrumentation/rails_action_view_test.rb
|
|
299
|
+
- test/instrumentation/rails_active_job_test.rb
|
|
305
300
|
- test/instrumentation/rails_active_record_test.rb
|
|
306
301
|
- test/instrumentation/redis_test.rb
|
|
307
302
|
- test/instrumentation/resque_test.rb
|
|
@@ -369,80 +364,81 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
369
364
|
- !ruby/object:Gem::Version
|
|
370
365
|
version: '0'
|
|
371
366
|
requirements: []
|
|
372
|
-
rubygems_version: 3.
|
|
367
|
+
rubygems_version: 3.1.6
|
|
373
368
|
signing_key:
|
|
374
369
|
specification_version: 4
|
|
375
370
|
summary: Ruby Distributed Tracing & Metrics Sensor for Instana
|
|
376
371
|
test_files:
|
|
377
|
-
- test/config_test.rb
|
|
378
|
-
- test/serverless_test.rb
|
|
379
372
|
- test/activator_test.rb
|
|
380
|
-
- test/
|
|
381
|
-
- test/tracing/span_test.rb
|
|
382
|
-
- test/tracing/id_management_test.rb
|
|
383
|
-
- test/tracing/tracer_test.rb
|
|
384
|
-
- test/tracing/custom_test.rb
|
|
385
|
-
- test/tracing/opentracing_test.rb
|
|
386
|
-
- test/tracing/tracer_async_test.rb
|
|
387
|
-
- test/tracing/processor_test.rb
|
|
388
|
-
- test/snapshot/docker_container_test.rb
|
|
389
|
-
- test/snapshot/fargate_process_test.rb
|
|
390
|
-
- test/snapshot/deltable_test.rb
|
|
391
|
-
- test/snapshot/fargate_task_test.rb
|
|
392
|
-
- test/snapshot/ruby_process_test.rb
|
|
393
|
-
- test/snapshot/google_cloud_run_process_test.rb
|
|
394
|
-
- test/snapshot/lambda_function_test.rb
|
|
395
|
-
- test/snapshot/fargate_container_test.rb
|
|
396
|
-
- test/snapshot/google_cloud_run_instance_test.rb
|
|
397
|
-
- test/backend/host_agent_activation_observer_test.rb
|
|
398
|
-
- test/backend/host_agent_reporting_observer_test.rb
|
|
373
|
+
- test/backend/agent_test.rb
|
|
399
374
|
- test/backend/gc_snapshot_test.rb
|
|
375
|
+
- test/backend/host_agent_activation_observer_test.rb
|
|
400
376
|
- test/backend/host_agent_lookup_test.rb
|
|
401
|
-
- test/backend/
|
|
402
|
-
- test/backend/process_info_test.rb
|
|
403
|
-
- test/backend/agent_test.rb
|
|
377
|
+
- test/backend/host_agent_reporting_observer_test.rb
|
|
404
378
|
- test/backend/host_agent_test.rb
|
|
379
|
+
- test/backend/process_info_test.rb
|
|
405
380
|
- test/backend/request_client_test.rb
|
|
406
|
-
- test/
|
|
381
|
+
- test/backend/serverless_agent_test.rb
|
|
382
|
+
- test/benchmarks/bench_id_generation.rb
|
|
383
|
+
- test/benchmarks/bench_opentracing.rb
|
|
384
|
+
- test/config_test.rb
|
|
385
|
+
- test/frameworks/cuba_test.rb
|
|
386
|
+
- test/frameworks/roda_test.rb
|
|
387
|
+
- test/frameworks/sinatra_test.rb
|
|
388
|
+
- test/instana_test.rb
|
|
389
|
+
- test/instrumentation/aws_test.rb
|
|
390
|
+
- test/instrumentation/dalli_test.rb
|
|
391
|
+
- test/instrumentation/excon_test.rb
|
|
407
392
|
- test/instrumentation/graphql_test.rb
|
|
408
|
-
- test/instrumentation/
|
|
409
|
-
- test/instrumentation/rails_action_controller_test.rb
|
|
410
|
-
- test/instrumentation/rest_client_test.rb
|
|
393
|
+
- test/instrumentation/grpc_test.rb
|
|
411
394
|
- test/instrumentation/net_http_test.rb
|
|
412
|
-
- test/instrumentation/resque_test.rb
|
|
413
|
-
- test/instrumentation/sidekiq-worker_test.rb
|
|
414
|
-
- test/instrumentation/rails_action_view_test.rb
|
|
415
|
-
- test/instrumentation/rack_test.rb
|
|
416
395
|
- test/instrumentation/rack_instrumented_request_test.rb
|
|
417
|
-
- test/instrumentation/
|
|
396
|
+
- test/instrumentation/rack_test.rb
|
|
397
|
+
- test/instrumentation/rails_action_cable_test.rb
|
|
398
|
+
- test/instrumentation/rails_action_controller_test.rb
|
|
399
|
+
- test/instrumentation/rails_action_view_test.rb
|
|
400
|
+
- test/instrumentation/rails_active_job_test.rb
|
|
418
401
|
- test/instrumentation/rails_active_record_test.rb
|
|
419
402
|
- test/instrumentation/redis_test.rb
|
|
420
|
-
- test/instrumentation/
|
|
421
|
-
- test/instrumentation/
|
|
422
|
-
- test/instrumentation/
|
|
423
|
-
- test/instrumentation/
|
|
424
|
-
- test/instrumentation/
|
|
425
|
-
- test/
|
|
426
|
-
- test/
|
|
427
|
-
- test/
|
|
428
|
-
- test/
|
|
429
|
-
- test/
|
|
430
|
-
- test/
|
|
431
|
-
- test/
|
|
403
|
+
- test/instrumentation/resque_test.rb
|
|
404
|
+
- test/instrumentation/rest_client_test.rb
|
|
405
|
+
- test/instrumentation/shoryuken_test.rb
|
|
406
|
+
- test/instrumentation/sidekiq-client_test.rb
|
|
407
|
+
- test/instrumentation/sidekiq-worker_test.rb
|
|
408
|
+
- test/secrets_test.rb
|
|
409
|
+
- test/serverless_test.rb
|
|
410
|
+
- test/snapshot/deltable_test.rb
|
|
411
|
+
- test/snapshot/docker_container_test.rb
|
|
412
|
+
- test/snapshot/fargate_container_test.rb
|
|
413
|
+
- test/snapshot/fargate_process_test.rb
|
|
414
|
+
- test/snapshot/fargate_task_test.rb
|
|
415
|
+
- test/snapshot/google_cloud_run_instance_test.rb
|
|
416
|
+
- test/snapshot/google_cloud_run_process_test.rb
|
|
417
|
+
- test/snapshot/lambda_function_test.rb
|
|
418
|
+
- test/snapshot/ruby_process_test.rb
|
|
419
|
+
- test/support/apps/active_record/active_record.rb
|
|
432
420
|
- test/support/apps/grpc/boot.rb
|
|
433
421
|
- test/support/apps/grpc/grpc_server.rb
|
|
434
|
-
- test/support/apps/active_record/active_record.rb
|
|
435
|
-
- test/support/apps/resque/boot.rb
|
|
436
|
-
- test/support/apps/resque/jobs/resque_error_job.rb
|
|
437
|
-
- test/support/apps/resque/jobs/resque_fast_job.rb
|
|
438
422
|
- test/support/apps/http_endpoint/boot.rb
|
|
423
|
+
- test/support/apps/rails/boot.rb
|
|
439
424
|
- test/support/apps/rails/models/block.rb
|
|
440
425
|
- test/support/apps/rails/models/block6.rb
|
|
441
|
-
- test/support/apps/
|
|
442
|
-
- test/
|
|
443
|
-
- test/
|
|
426
|
+
- test/support/apps/resque/boot.rb
|
|
427
|
+
- test/support/apps/resque/jobs/resque_error_job.rb
|
|
428
|
+
- test/support/apps/resque/jobs/resque_fast_job.rb
|
|
429
|
+
- test/support/apps/sidekiq/boot.rb
|
|
430
|
+
- test/support/apps/sidekiq/jobs/sidekiq_job_1.rb
|
|
431
|
+
- test/support/apps/sidekiq/jobs/sidekiq_job_2.rb
|
|
432
|
+
- test/support/apps/sidekiq/worker.rb
|
|
433
|
+
- test/support/helpers.rb
|
|
434
|
+
- test/support/mock_timer.rb
|
|
444
435
|
- test/test_helper.rb
|
|
445
|
-
- test/
|
|
446
|
-
- test/
|
|
447
|
-
- test/
|
|
448
|
-
- test/
|
|
436
|
+
- test/tracing/custom_test.rb
|
|
437
|
+
- test/tracing/id_management_test.rb
|
|
438
|
+
- test/tracing/opentracing_test.rb
|
|
439
|
+
- test/tracing/processor_test.rb
|
|
440
|
+
- test/tracing/span_context_test.rb
|
|
441
|
+
- test/tracing/span_test.rb
|
|
442
|
+
- test/tracing/tracer_async_test.rb
|
|
443
|
+
- test/tracing/tracer_test.rb
|
|
444
|
+
- test/util_test.rb
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# (c) Copyright IBM Corp. 2021
|
|
2
|
-
# (c) Copyright Instana Inc. 2017
|
|
3
|
-
|
|
4
|
-
require "bundler"
|
|
5
|
-
|
|
6
|
-
require 'rack'
|
|
7
|
-
require 'rack/builder'
|
|
8
|
-
require 'rack/handler/puma'
|
|
9
|
-
require 'net/http'
|
|
10
|
-
require "cgi"
|
|
11
|
-
Bundler.require(:default)
|
|
12
|
-
require "instana/rack"
|
|
13
|
-
require 'ruby-prof'
|
|
14
|
-
|
|
15
|
-
Thread.new do
|
|
16
|
-
app = Rack::Builder.new {
|
|
17
|
-
map "/" do
|
|
18
|
-
run Proc.new {
|
|
19
|
-
[200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
|
|
20
|
-
}
|
|
21
|
-
end
|
|
22
|
-
map "/error" do
|
|
23
|
-
run Proc.new {
|
|
24
|
-
[500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7011})
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
Thread.new do
|
|
33
|
-
app = Rack::Builder.new {
|
|
34
|
-
use ::Instana::Rack
|
|
35
|
-
map "/" do
|
|
36
|
-
run Proc.new {
|
|
37
|
-
[200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
|
|
38
|
-
}
|
|
39
|
-
end
|
|
40
|
-
map "/error" do
|
|
41
|
-
run Proc.new {
|
|
42
|
-
[500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
|
|
43
|
-
}
|
|
44
|
-
end
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7012})
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
puts ""
|
|
51
|
-
puts "Vanilla Rack server started in background thread on localhost:7011"
|
|
52
|
-
puts "Instrumented Rack server started in background thread on localhost:7012"
|
|
53
|
-
puts ""
|
|
54
|
-
puts "Waiting on successful announce to host agent..."
|
|
55
|
-
puts ""
|
|
56
|
-
|
|
57
|
-
#RubyProf.measure_mode = RubyProf::WALL_TIME
|
|
58
|
-
#RubyProf.measure_mode = RubyProf::PROCESS_TIME
|
|
59
|
-
RubyProf.measure_mode = RubyProf::ALLOCATIONS
|
|
60
|
-
#RubyProf.measure_mode = RubyProf::MEMORY
|
|
61
|
-
|
|
62
|
-
while !::Instana.agent.ready? do
|
|
63
|
-
sleep 2
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
puts "Starting 10k Traces..."
|
|
67
|
-
|
|
68
|
-
# uri = URI.parse("http://127.0.0.1:7011/")
|
|
69
|
-
# ::Net::HTTP.start(uri.host, uri.port) do |hc|
|
|
70
|
-
# x.report("vanilla") {
|
|
71
|
-
# 10_000.times {
|
|
72
|
-
# req = Net::HTTP::Get.new(uri.request_uri)
|
|
73
|
-
# hc.request(req)
|
|
74
|
-
# }
|
|
75
|
-
# }
|
|
76
|
-
# end
|
|
77
|
-
|
|
78
|
-
uri = URI.parse("http://127.0.0.1:7012/")
|
|
79
|
-
result = RubyProf.profile do
|
|
80
|
-
1.times {
|
|
81
|
-
::Instana.tracer.start_or_continue_trace(:job, {:kind => :entry}) do
|
|
82
|
-
::Net::HTTP.start(uri.host, uri.port) do |hc|
|
|
83
|
-
::Instana.tracer.start_or_continue_trace(:rack_call) do
|
|
84
|
-
req = Net::HTTP::Get.new(uri.request_uri)
|
|
85
|
-
hc.request(req)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
}
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
puts "Done - displaying results..."
|
|
93
|
-
|
|
94
|
-
printer = RubyProf::FlatPrinter.new(result)
|
|
95
|
-
printer.print(STDOUT, {})
|
data/benchmarks/Gemfile
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# (c) Copyright IBM Corp. 2021
|
|
4
|
-
# (c) Copyright Instana Inc. 2017
|
|
5
|
-
|
|
6
|
-
source "https://rubygems.org"
|
|
7
|
-
|
|
8
|
-
git_source(:github) {|repo_name| "https://github.com/instana/#{repo_name}" }
|
|
9
|
-
|
|
10
|
-
gem "instana", :path => "~/Projects/instana/ruby-sensor"
|
|
11
|
-
|
data/benchmarks/Gemfile.lock
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ..
|
|
3
|
-
specs:
|
|
4
|
-
instana (1.9.6)
|
|
5
|
-
ffi (>= 1.0.11)
|
|
6
|
-
get_process_mem (>= 0.2.1)
|
|
7
|
-
oj (>= 3.0.11)
|
|
8
|
-
sys-proctable (>= 0.9.2)
|
|
9
|
-
timers (>= 4.0.0)
|
|
10
|
-
|
|
11
|
-
GEM
|
|
12
|
-
remote: https://rubygems.org/
|
|
13
|
-
specs:
|
|
14
|
-
ffi (1.11.1)
|
|
15
|
-
get_process_mem (0.2.4)
|
|
16
|
-
ffi (~> 1.0)
|
|
17
|
-
nio4r (2.4.0)
|
|
18
|
-
oj (3.8.1)
|
|
19
|
-
puma (4.1.0)
|
|
20
|
-
nio4r (~> 2.0)
|
|
21
|
-
rack (2.0.7)
|
|
22
|
-
ruby-prof (1.0.0)
|
|
23
|
-
sys-proctable (1.2.2)
|
|
24
|
-
ffi
|
|
25
|
-
timers (4.3.0)
|
|
26
|
-
|
|
27
|
-
PLATFORMS
|
|
28
|
-
ruby
|
|
29
|
-
x86_64-darwin-18
|
|
30
|
-
|
|
31
|
-
DEPENDENCIES
|
|
32
|
-
instana!
|
|
33
|
-
puma
|
|
34
|
-
rack
|
|
35
|
-
ruby-prof
|
|
36
|
-
|
|
37
|
-
BUNDLED WITH
|
|
38
|
-
2.0.2
|
data/benchmarks/id_generation.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
# (c) Copyright IBM Corp. 2021
|
|
4
|
-
# (c) Copyright Instana Inc. 2017
|
|
5
|
-
|
|
6
|
-
require "bundler"
|
|
7
|
-
Bundler.require(:default)
|
|
8
|
-
|
|
9
|
-
require "benchmark"
|
|
10
|
-
|
|
11
|
-
ID_RANGE = -2**63..2**63-1
|
|
12
|
-
|
|
13
|
-
Benchmark.bm do |x|
|
|
14
|
-
x.report("generate_id raw ") { 1_000_000.times { rand(-2**63..2**63-1) } }
|
|
15
|
-
x.report("with fixed range ") { 1_000_000.times { rand(ID_RANGE) } }
|
|
16
|
-
end
|
data/benchmarks/opentracing.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
# (c) Copyright IBM Corp. 2021
|
|
4
|
-
# (c) Copyright Instana Inc. 2017
|
|
5
|
-
|
|
6
|
-
require "bundler"
|
|
7
|
-
Bundler.require(:default)
|
|
8
|
-
|
|
9
|
-
require "benchmark"
|
|
10
|
-
|
|
11
|
-
Benchmark.bm do |x|
|
|
12
|
-
x.report("start_span, finish: ") {
|
|
13
|
-
50_000.times {
|
|
14
|
-
::Instana.tracer.start_span(:blah).finish
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
x.report("start_span, set_tag(5x), finish:") {
|
|
19
|
-
50_000.times {
|
|
20
|
-
span = ::Instana.tracer.start_span(:blah)
|
|
21
|
-
span.set_tag(:blah, 1)
|
|
22
|
-
span.set_tag(:dog, 1)
|
|
23
|
-
span.set_tag(:moon, "ok")
|
|
24
|
-
span.set_tag(:ape, 1)
|
|
25
|
-
span.set_tag(:blah, 1)
|
|
26
|
-
span.finish
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
end
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# (c) Copyright IBM Corp. 2021
|
|
2
|
-
# (c) Copyright Instana Inc. 2017
|
|
3
|
-
|
|
4
|
-
require "bundler"
|
|
5
|
-
|
|
6
|
-
require 'rack'
|
|
7
|
-
require 'rack/builder'
|
|
8
|
-
require 'rack/handler/puma'
|
|
9
|
-
require 'net/http'
|
|
10
|
-
require "benchmark"
|
|
11
|
-
require "cgi"
|
|
12
|
-
Bundler.require(:default)
|
|
13
|
-
require "instana/rack"
|
|
14
|
-
|
|
15
|
-
Thread.new do
|
|
16
|
-
app = Rack::Builder.new {
|
|
17
|
-
map "/" do
|
|
18
|
-
run Proc.new {
|
|
19
|
-
[200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
|
|
20
|
-
}
|
|
21
|
-
end
|
|
22
|
-
map "/error" do
|
|
23
|
-
run Proc.new {
|
|
24
|
-
[500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7011})
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
Thread.new do
|
|
33
|
-
app = Rack::Builder.new {
|
|
34
|
-
use ::Instana::Rack
|
|
35
|
-
map "/" do
|
|
36
|
-
run Proc.new {
|
|
37
|
-
[200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
|
|
38
|
-
}
|
|
39
|
-
end
|
|
40
|
-
map "/error" do
|
|
41
|
-
run Proc.new {
|
|
42
|
-
[500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
|
|
43
|
-
}
|
|
44
|
-
end
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7012})
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
puts ""
|
|
51
|
-
puts "Vanilla Rack server started in background thread on localhost:7011"
|
|
52
|
-
puts "Instrumented Rack server started in background thread on localhost:7012"
|
|
53
|
-
puts ""
|
|
54
|
-
puts "Waiting on successful announce to host agent..."
|
|
55
|
-
puts ""
|
|
56
|
-
|
|
57
|
-
while !::Instana.agent.ready? do
|
|
58
|
-
sleep 2
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
puts "Starting benchmarks"
|
|
62
|
-
Benchmark.bm do |x|
|
|
63
|
-
|
|
64
|
-
uri = URI.parse("http://127.0.0.1:7011/")
|
|
65
|
-
::Net::HTTP.start(uri.host, uri.port) do |hc|
|
|
66
|
-
x.report("vanilla") {
|
|
67
|
-
1_000.times {
|
|
68
|
-
req = Net::HTTP::Get.new(uri.request_uri)
|
|
69
|
-
hc.request(req)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
uri = URI.parse("http://127.0.0.1:7012/")
|
|
75
|
-
::Net::HTTP.start(uri.host, uri.port) do |hc|
|
|
76
|
-
x.report("traced ") {
|
|
77
|
-
1_000.times {
|
|
78
|
-
::Instana.tracer.start_or_continue_trace(:rack_call) do
|
|
79
|
-
req = Net::HTTP::Get.new(uri.request_uri)
|
|
80
|
-
hc.request(req)
|
|
81
|
-
end
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
sleep 10
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# (c) Copyright IBM Corp. 2021
|
|
2
|
-
# (c) Copyright Instana Inc. 2017
|
|
3
|
-
|
|
4
|
-
require "bundler"
|
|
5
|
-
require "stackprof"
|
|
6
|
-
require 'rack'
|
|
7
|
-
require 'rack/builder'
|
|
8
|
-
require 'rack/handler/puma'
|
|
9
|
-
require 'net/http'
|
|
10
|
-
require "benchmark"
|
|
11
|
-
require "cgi"
|
|
12
|
-
Bundler.require(:default)
|
|
13
|
-
require "instana/rack"
|
|
14
|
-
|
|
15
|
-
Thread.new do
|
|
16
|
-
app = Rack::Builder.new {
|
|
17
|
-
map "/" do
|
|
18
|
-
run Proc.new {
|
|
19
|
-
[200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
|
|
20
|
-
}
|
|
21
|
-
end
|
|
22
|
-
map "/error" do
|
|
23
|
-
run Proc.new {
|
|
24
|
-
[500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7011})
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
Thread.new do
|
|
33
|
-
app = Rack::Builder.new {
|
|
34
|
-
use ::Instana::Rack
|
|
35
|
-
map "/" do
|
|
36
|
-
run Proc.new {
|
|
37
|
-
[200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
|
|
38
|
-
}
|
|
39
|
-
end
|
|
40
|
-
map "/error" do
|
|
41
|
-
run Proc.new {
|
|
42
|
-
[500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
|
|
43
|
-
}
|
|
44
|
-
end
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 7012})
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
sleep(2)
|
|
51
|
-
puts "Rack server started in background thread on localhost:7011"
|
|
52
|
-
puts "Sleeping for 10 to allow announce"
|
|
53
|
-
sleep(10)
|
|
54
|
-
|
|
55
|
-
puts "Starting profile"
|
|
56
|
-
uri = URI.parse("http://127.0.0.1:7011/")
|
|
57
|
-
StackProf.run(mode: :wall, out: 'tmp/stackprof-rack-vanilla.dump') do
|
|
58
|
-
::Net::HTTP.start(uri.host, uri.port) do |hc|
|
|
59
|
-
5_000.times {
|
|
60
|
-
::Instana.tracer.start_or_continue_trace(:rack_call) do
|
|
61
|
-
req = Net::HTTP::Get.new(uri.request_uri)
|
|
62
|
-
hc.request(req)
|
|
63
|
-
end
|
|
64
|
-
}
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
puts "stackprof tmp/stackprof-rack-vanilla.dump --text"
|
|
68
|
-
|
|
69
|
-
uri = URI.parse("http://127.0.0.1:7012/")
|
|
70
|
-
StackProf.run(mode: :wall, out: 'tmp/stackprof-rack-instrumented.dump') do
|
|
71
|
-
::Net::HTTP.start(uri.host, uri.port) do |hc|
|
|
72
|
-
5_000.times {
|
|
73
|
-
::Instana.tracer.start_or_continue_trace(:rack_call) do
|
|
74
|
-
req = Net::HTTP::Get.new(uri.request_uri)
|
|
75
|
-
hc.request(req)
|
|
76
|
-
end
|
|
77
|
-
}
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
puts "stackprof tmp/stackprof-rack-instrumented.dump --text"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
# (c) Copyright IBM Corp. 2021
|
|
4
|
-
# (c) Copyright Instana Inc. 2017
|
|
5
|
-
|
|
6
|
-
require "bundler"
|
|
7
|
-
Bundler.require(:default)
|
|
8
|
-
|
|
9
|
-
require "benchmark"
|
|
10
|
-
|
|
11
|
-
# Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
|
|
12
|
-
|
|
13
|
-
Benchmark.bm do |x|
|
|
14
|
-
x.report("Time.now: ") { 1_000_000.times { (Time.now.to_f * 1000).floor } }
|
|
15
|
-
x.report("get_clocktime:") { 1_000_000.times { Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond) } }
|
|
16
|
-
end
|