instana 1.199.2 → 1.200.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +27 -1
- data/lib/instana.rb +2 -4
- data/lib/instana/activators/resque_worker.rb +4 -5
- data/lib/instana/backend/host_agent.rb +16 -10
- data/lib/instana/backend/host_agent_activation_observer.rb +2 -2
- data/lib/instana/backend/serverless_agent.rb +3 -0
- data/lib/instana/config.rb +3 -1
- data/lib/instana/setup.rb +3 -1
- data/lib/instana/tracing/processor.rb +8 -5
- data/lib/instana/version.rb +1 -1
- data/test/backend/host_agent_test.rb +10 -0
- data/test/backend/serverless_agent_test.rb +10 -0
- data/test/secrets_test.rb +0 -2
- metadata +61 -69
- 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: 97f4147730556687389966d4b2403b5f12087b2479926bb671683ff6056b2f10
|
4
|
+
data.tar.gz: 64259bb574f226a81834402180083c4f04303a4d7db1cb6573645357dbb7b3aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74fdc725df175bf8dce646c438851298515f1a73caa57b7de679295c8f05eb2abef81629b183ef231358c919646ca7d85fc63d5103e91a74916e4b1fb0ab5493
|
7
|
+
data.tar.gz: 9010fe9c2cdd2108bc2a7540bd1704981aaa81370c02847c83af8b177a4303a8ac23c1a990cab8fff141c32bc5a7621fda0c397e19338c4f50e166eece316dc6
|
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/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
|
@@ -16,11 +16,10 @@ module Instana
|
|
16
16
|
::Resque::Worker.prepend(::Instana::Instrumentation::ResqueWorker)
|
17
17
|
::Resque::Job.prepend(::Instana::Instrumentation::ResqueJob)
|
18
18
|
|
19
|
-
::
|
20
|
-
::
|
21
|
-
|
22
|
-
|
23
|
-
::Instana.agent.after_resque_fork
|
19
|
+
if ::Instana.config[:'resque-worker'][:'setup-fork']
|
20
|
+
::Resque.after_fork do |_job|
|
21
|
+
::Instana.agent.after_fork
|
22
|
+
end
|
24
23
|
end
|
25
24
|
|
26
25
|
# Set this so we assure that any remaining collected traces are reported at_exit
|
@@ -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
|
@@ -19,19 +20,24 @@ module Instana
|
|
19
20
|
return if ENV.key?('INSTANA_TEST')
|
20
21
|
|
21
22
|
@future = Concurrent::Promises.future do
|
22
|
-
|
23
|
-
@discovery.delete_observers
|
24
|
-
@discovery
|
25
|
-
.with_observer(HostAgentActivationObserver.new(client, @discovery))
|
26
|
-
.with_observer(HostAgentReportingObserver.new(client, @discovery))
|
27
|
-
|
28
|
-
@discovery.swap { nil }
|
29
|
-
client
|
23
|
+
announce
|
30
24
|
end
|
31
25
|
end
|
32
26
|
|
33
27
|
alias start spawn_background_thread
|
34
|
-
|
28
|
+
|
29
|
+
def announce
|
30
|
+
@client = until_not_nil { HostAgentLookup.new.call }
|
31
|
+
@discovery.delete_observers
|
32
|
+
@discovery
|
33
|
+
.with_observer(HostAgentActivationObserver.new(@client, @discovery))
|
34
|
+
.with_observer(HostAgentReportingObserver.new(@client, @discovery))
|
35
|
+
|
36
|
+
@discovery.swap { nil }
|
37
|
+
@client
|
38
|
+
end
|
39
|
+
|
40
|
+
alias after_fork announce
|
35
41
|
|
36
42
|
# @return [Boolean] true if the agent able to send spans to the backend
|
37
43
|
def ready?
|
@@ -12,7 +12,7 @@ module Instana
|
|
12
12
|
|
13
13
|
# @param [RequestClient] client used to make requests to the backend
|
14
14
|
# @param [Concurrent::Atom] discovery object used to store discovery response in
|
15
|
-
def initialize(client, discovery, wait_time:
|
15
|
+
def initialize(client, discovery, wait_time: 30, logger: ::Instana.logger, max_wait_tries: 60, proc_table: Sys::ProcTable, socket_proc: default_socket_proc) # rubocop:disable Metrics/ParameterLists
|
16
16
|
@client = client
|
17
17
|
@discovery = discovery
|
18
18
|
@wait_time = wait_time
|
@@ -82,7 +82,7 @@ module Instana
|
|
82
82
|
def try_forever_with_backoff
|
83
83
|
yield
|
84
84
|
rescue DiscoveryError, Net::OpenTimeout => e
|
85
|
-
@logger.
|
85
|
+
@logger.debug(e)
|
86
86
|
sleep(@wait_time)
|
87
87
|
retry
|
88
88
|
rescue StandardError => e
|
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 }
|
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/version.rb
CHANGED
@@ -44,4 +44,14 @@ class HostAgentTest < Minitest::Test
|
|
44
44
|
subject = Instana::Backend::HostAgent.new(discovery: discovery)
|
45
45
|
assert_equal 1, subject.source[:e]
|
46
46
|
end
|
47
|
+
|
48
|
+
def test_start
|
49
|
+
subject = Instana::Backend::HostAgent.new
|
50
|
+
assert subject.respond_to? :start
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_after_fork
|
54
|
+
subject = Instana::Backend::HostAgent.new
|
55
|
+
assert subject.respond_to? :after_fork
|
56
|
+
end
|
47
57
|
end
|
@@ -70,4 +70,14 @@ class ServerlesAgentTest < Minitest::Test
|
|
70
70
|
|
71
71
|
subject.timer.block.call
|
72
72
|
end
|
73
|
+
|
74
|
+
def test_start
|
75
|
+
subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/', logger: Logger.new('/dev/null'))
|
76
|
+
assert subject.respond_to? :start
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_after_fork
|
80
|
+
subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/', logger: Logger.new('/dev/null'))
|
81
|
+
assert subject.respond_to? :after_fork
|
82
|
+
end
|
73
83
|
end
|
data/test/secrets_test.rb
CHANGED
@@ -98,8 +98,6 @@ class SecretsTest < Minitest::Test
|
|
98
98
|
|
99
99
|
def assert_redacted(str, keys, raw_str: false)
|
100
100
|
params = raw_str ? CGI.parse(str) : CGI.parse(URI(str).query)
|
101
|
-
pp params
|
102
|
-
|
103
101
|
assert_equal keys, params.select { |_, v| v == %w(<redacted>) }.keys, 'to be redacted'
|
104
102
|
end
|
105
103
|
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.200.0.pre1
|
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-07 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
|
@@ -365,84 +357,84 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
365
357
|
version: '2.1'
|
366
358
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
367
359
|
requirements:
|
368
|
-
- - "
|
360
|
+
- - ">"
|
369
361
|
- !ruby/object:Gem::Version
|
370
|
-
version:
|
362
|
+
version: 1.3.1
|
371
363
|
requirements: []
|
372
|
-
rubygems_version: 3.
|
364
|
+
rubygems_version: 3.1.6
|
373
365
|
signing_key:
|
374
366
|
specification_version: 4
|
375
367
|
summary: Ruby Distributed Tracing & Metrics Sensor for Instana
|
376
368
|
test_files:
|
377
|
-
- test/config_test.rb
|
378
|
-
- test/serverless_test.rb
|
379
369
|
- 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
|
370
|
+
- test/backend/agent_test.rb
|
399
371
|
- test/backend/gc_snapshot_test.rb
|
372
|
+
- test/backend/host_agent_activation_observer_test.rb
|
400
373
|
- test/backend/host_agent_lookup_test.rb
|
401
|
-
- test/backend/
|
402
|
-
- test/backend/process_info_test.rb
|
403
|
-
- test/backend/agent_test.rb
|
374
|
+
- test/backend/host_agent_reporting_observer_test.rb
|
404
375
|
- test/backend/host_agent_test.rb
|
376
|
+
- test/backend/process_info_test.rb
|
405
377
|
- test/backend/request_client_test.rb
|
406
|
-
- test/
|
378
|
+
- test/backend/serverless_agent_test.rb
|
379
|
+
- test/benchmarks/bench_id_generation.rb
|
380
|
+
- test/benchmarks/bench_opentracing.rb
|
381
|
+
- test/config_test.rb
|
382
|
+
- test/frameworks/cuba_test.rb
|
383
|
+
- test/frameworks/roda_test.rb
|
384
|
+
- test/frameworks/sinatra_test.rb
|
385
|
+
- test/instana_test.rb
|
386
|
+
- test/instrumentation/aws_test.rb
|
387
|
+
- test/instrumentation/dalli_test.rb
|
388
|
+
- test/instrumentation/excon_test.rb
|
407
389
|
- test/instrumentation/graphql_test.rb
|
408
|
-
- test/instrumentation/
|
409
|
-
- test/instrumentation/rails_action_controller_test.rb
|
410
|
-
- test/instrumentation/rest_client_test.rb
|
390
|
+
- test/instrumentation/grpc_test.rb
|
411
391
|
- 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
392
|
- test/instrumentation/rack_instrumented_request_test.rb
|
417
|
-
- test/instrumentation/
|
393
|
+
- test/instrumentation/rack_test.rb
|
394
|
+
- test/instrumentation/rails_action_cable_test.rb
|
395
|
+
- test/instrumentation/rails_action_controller_test.rb
|
396
|
+
- test/instrumentation/rails_action_view_test.rb
|
418
397
|
- test/instrumentation/rails_active_record_test.rb
|
419
398
|
- 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/
|
399
|
+
- test/instrumentation/resque_test.rb
|
400
|
+
- test/instrumentation/rest_client_test.rb
|
401
|
+
- test/instrumentation/shoryuken_test.rb
|
402
|
+
- test/instrumentation/sidekiq-client_test.rb
|
403
|
+
- test/instrumentation/sidekiq-worker_test.rb
|
404
|
+
- test/secrets_test.rb
|
405
|
+
- test/serverless_test.rb
|
406
|
+
- test/snapshot/deltable_test.rb
|
407
|
+
- test/snapshot/docker_container_test.rb
|
408
|
+
- test/snapshot/fargate_container_test.rb
|
409
|
+
- test/snapshot/fargate_process_test.rb
|
410
|
+
- test/snapshot/fargate_task_test.rb
|
411
|
+
- test/snapshot/google_cloud_run_instance_test.rb
|
412
|
+
- test/snapshot/google_cloud_run_process_test.rb
|
413
|
+
- test/snapshot/lambda_function_test.rb
|
414
|
+
- test/snapshot/ruby_process_test.rb
|
415
|
+
- test/support/apps/active_record/active_record.rb
|
432
416
|
- test/support/apps/grpc/boot.rb
|
433
417
|
- 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
418
|
- test/support/apps/http_endpoint/boot.rb
|
419
|
+
- test/support/apps/rails/boot.rb
|
439
420
|
- test/support/apps/rails/models/block.rb
|
440
421
|
- test/support/apps/rails/models/block6.rb
|
441
|
-
- test/support/apps/
|
442
|
-
- test/
|
443
|
-
- test/
|
422
|
+
- test/support/apps/resque/boot.rb
|
423
|
+
- test/support/apps/resque/jobs/resque_error_job.rb
|
424
|
+
- test/support/apps/resque/jobs/resque_fast_job.rb
|
425
|
+
- test/support/apps/sidekiq/boot.rb
|
426
|
+
- test/support/apps/sidekiq/jobs/sidekiq_job_1.rb
|
427
|
+
- test/support/apps/sidekiq/jobs/sidekiq_job_2.rb
|
428
|
+
- test/support/apps/sidekiq/worker.rb
|
429
|
+
- test/support/helpers.rb
|
430
|
+
- test/support/mock_timer.rb
|
444
431
|
- test/test_helper.rb
|
445
|
-
- test/
|
446
|
-
- test/
|
447
|
-
- test/
|
448
|
-
- test/
|
432
|
+
- test/tracing/custom_test.rb
|
433
|
+
- test/tracing/id_management_test.rb
|
434
|
+
- test/tracing/opentracing_test.rb
|
435
|
+
- test/tracing/processor_test.rb
|
436
|
+
- test/tracing/span_context_test.rb
|
437
|
+
- test/tracing/span_test.rb
|
438
|
+
- test/tracing/tracer_async_test.rb
|
439
|
+
- test/tracing/tracer_test.rb
|
440
|
+
- 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
|