instana 1.217.1 → 2.1.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.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/lib/instana/base.rb +4 -2
  4. data/lib/instana/instrumentation/action_cable.rb +8 -4
  5. data/lib/instana/instrumentation/action_controller.rb +2 -4
  6. data/lib/instana/instrumentation/action_mailer.rb +1 -1
  7. data/lib/instana/instrumentation/action_view.rb +4 -4
  8. data/lib/instana/instrumentation/active_job.rb +20 -5
  9. data/lib/instana/instrumentation/active_record.rb +1 -1
  10. data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +1 -1
  11. data/lib/instana/instrumentation/aws_sdk_lambda.rb +1 -1
  12. data/lib/instana/instrumentation/aws_sdk_s3.rb +1 -1
  13. data/lib/instana/instrumentation/aws_sdk_sns.rb +1 -1
  14. data/lib/instana/instrumentation/aws_sdk_sqs.rb +1 -1
  15. data/lib/instana/instrumentation/dalli.rb +1 -1
  16. data/lib/instana/instrumentation/excon.rb +2 -2
  17. data/lib/instana/instrumentation/graphql.rb +3 -3
  18. data/lib/instana/instrumentation/grpc.rb +14 -13
  19. data/lib/instana/instrumentation/mongo.rb +3 -3
  20. data/lib/instana/instrumentation/net-http.rb +5 -4
  21. data/lib/instana/instrumentation/rack.rb +36 -4
  22. data/lib/instana/instrumentation/redis.rb +1 -1
  23. data/lib/instana/instrumentation/resque.rb +10 -8
  24. data/lib/instana/instrumentation/rest-client.rb +4 -4
  25. data/lib/instana/instrumentation/sequel.rb +3 -3
  26. data/lib/instana/instrumentation/shoryuken.rb +4 -1
  27. data/lib/instana/instrumentation/sidekiq-client.rb +21 -19
  28. data/lib/instana/instrumentation/sidekiq-worker.rb +22 -21
  29. data/lib/instana/instrumented_logger.rb +1 -1
  30. data/lib/instana/samplers/result.rb +32 -0
  31. data/lib/instana/samplers/samplers.rb +76 -0
  32. data/lib/instana/serverless.rb +4 -2
  33. data/lib/instana/setup.rb +5 -5
  34. data/lib/instana/span_filtering/condition.rb +134 -0
  35. data/lib/instana/span_filtering/configuration.rb +262 -0
  36. data/lib/instana/span_filtering/filter_rule.rb +31 -0
  37. data/lib/instana/span_filtering.rb +62 -0
  38. data/lib/instana/trace/export.rb +36 -0
  39. data/lib/instana/{tracing → trace}/processor.rb +19 -15
  40. data/lib/instana/trace/span.rb +534 -0
  41. data/lib/instana/{tracing → trace}/span_context.rb +17 -8
  42. data/lib/instana/trace/span_kind.rb +51 -0
  43. data/lib/instana/trace/span_limits.rb +63 -0
  44. data/lib/instana/{tracer.rb → trace/tracer.rb} +106 -54
  45. data/lib/instana/trace/tracer_provider.rb +198 -0
  46. data/lib/instana/trace.rb +74 -0
  47. data/lib/instana/util.rb +11 -0
  48. data/lib/instana/version.rb +1 -1
  49. metadata +89 -267
  50. data/.circleci/config.yml +0 -485
  51. data/.codeclimate.yml +0 -23
  52. data/.editorconfig +0 -10
  53. data/.fasterer.yml +0 -23
  54. data/.github/ISSUE_TEMPLATE/bug.yml +0 -39
  55. data/.github/ISSUE_TEMPLATE/config.yml +0 -8
  56. data/.github/workflows/pr_commits_signed_off.yml +0 -16
  57. data/.github/workflows/release-notification-on-slack.yml +0 -34
  58. data/.gitignore +0 -19
  59. data/.rubocop.yml +0 -34
  60. data/.rubocop_todo.yml +0 -1140
  61. data/.tekton/.currency/docs/report.md +0 -20
  62. data/.tekton/.currency/resources/requirements.txt +0 -4
  63. data/.tekton/.currency/resources/table.json +0 -100
  64. data/.tekton/.currency/scripts/generate_report.py +0 -136
  65. data/.tekton/README.md +0 -278
  66. data/.tekton/github-interceptor-secret.yaml +0 -8
  67. data/.tekton/github-pr-eventlistener.yaml +0 -104
  68. data/.tekton/github-pr-pipeline.yaml.part +0 -38
  69. data/.tekton/github-set-status-task.yaml +0 -43
  70. data/.tekton/github-webhook-ingress.yaml +0 -20
  71. data/.tekton/pipeline.yaml +0 -571
  72. data/.tekton/pipelinerun.yaml +0 -21
  73. data/.tekton/ruby-tracer-prepuller.yaml +0 -87
  74. data/.tekton/run_unittests.sh +0 -87
  75. data/.tekton/scheduled-eventlistener.yaml +0 -108
  76. data/.tekton/task.yaml +0 -449
  77. data/.tekton/tekton-triggers-eventlistener-serviceaccount.yaml +0 -29
  78. data/Appraisals +0 -124
  79. data/CONTRIBUTING.md +0 -86
  80. data/Gemfile +0 -17
  81. data/LICENSE +0 -22
  82. data/MAINTAINERS.md +0 -3
  83. data/Rakefile +0 -49
  84. data/bin/announce_release_on_slack.py +0 -103
  85. data/docker-compose.yml +0 -20
  86. data/download.sh +0 -85
  87. data/examples/opentracing.rb +0 -35
  88. data/examples/tracing.rb +0 -84
  89. data/extras/license_header.rb +0 -44
  90. data/gemfiles/.bundle/config +0 -2
  91. data/gemfiles/aws_30.gemfile +0 -21
  92. data/gemfiles/aws_60.gemfile +0 -16
  93. data/gemfiles/cuba_30.gemfile +0 -16
  94. data/gemfiles/cuba_40.gemfile +0 -13
  95. data/gemfiles/dalli_20.gemfile +0 -15
  96. data/gemfiles/dalli_30.gemfile +0 -12
  97. data/gemfiles/dalli_32.gemfile +0 -12
  98. data/gemfiles/excon_0100.gemfile +0 -14
  99. data/gemfiles/excon_021.gemfile +0 -17
  100. data/gemfiles/excon_079.gemfile +0 -17
  101. data/gemfiles/excon_100.gemfile +0 -14
  102. data/gemfiles/graphql_10.gemfile +0 -16
  103. data/gemfiles/graphql_20.gemfile +0 -15
  104. data/gemfiles/grpc_10.gemfile +0 -15
  105. data/gemfiles/mongo_216.gemfile +0 -15
  106. data/gemfiles/mongo_219.gemfile +0 -12
  107. data/gemfiles/net_http_01.gemfile +0 -17
  108. data/gemfiles/rack_16.gemfile +0 -15
  109. data/gemfiles/rack_20.gemfile +0 -15
  110. data/gemfiles/rack_30.gemfile +0 -13
  111. data/gemfiles/rails_42.gemfile +0 -18
  112. data/gemfiles/rails_50.gemfile +0 -19
  113. data/gemfiles/rails_52.gemfile +0 -19
  114. data/gemfiles/rails_60.gemfile +0 -19
  115. data/gemfiles/rails_61.gemfile +0 -20
  116. data/gemfiles/rails_70.gemfile +0 -17
  117. data/gemfiles/rails_71.gemfile +0 -17
  118. data/gemfiles/rails_80.gemfile +0 -17
  119. data/gemfiles/redis_40.gemfile +0 -15
  120. data/gemfiles/redis_50.gemfile +0 -13
  121. data/gemfiles/redis_51.gemfile +0 -13
  122. data/gemfiles/resque_122.gemfile +0 -16
  123. data/gemfiles/resque_1274_3scale.gemfile +0 -17
  124. data/gemfiles/resque_20.gemfile +0 -16
  125. data/gemfiles/rest_client_16.gemfile +0 -17
  126. data/gemfiles/rest_client_20.gemfile +0 -17
  127. data/gemfiles/roda_20.gemfile +0 -16
  128. data/gemfiles/roda_30.gemfile +0 -16
  129. data/gemfiles/rubocop_162.gemfile +0 -6
  130. data/gemfiles/sequel_56.gemfile +0 -16
  131. data/gemfiles/sequel_57.gemfile +0 -16
  132. data/gemfiles/sequel_58.gemfile +0 -16
  133. data/gemfiles/shoryuken_50.gemfile +0 -16
  134. data/gemfiles/shoryuken_60.gemfile +0 -13
  135. data/gemfiles/sidekiq_42.gemfile +0 -15
  136. data/gemfiles/sidekiq_50.gemfile +0 -15
  137. data/gemfiles/sidekiq_60.gemfile +0 -12
  138. data/gemfiles/sidekiq_65.gemfile +0 -12
  139. data/gemfiles/sidekiq_70.gemfile +0 -12
  140. data/gemfiles/sinatra_14.gemfile +0 -15
  141. data/gemfiles/sinatra_22.gemfile +0 -12
  142. data/gemfiles/sinatra_30.gemfile +0 -12
  143. data/gemfiles/sinatra_40.gemfile +0 -12
  144. data/instana.gemspec +0 -48
  145. data/lib/instana/open_tracing/carrier.rb +0 -7
  146. data/lib/instana/open_tracing/instana_tracer.rb +0 -99
  147. data/lib/instana/tracing/span.rb +0 -431
  148. data/lib/opentracing.rb +0 -32
  149. data/log/.keep +0 -0
  150. data/sonar-project.properties +0 -9
  151. data/test/activator_test.rb +0 -50
  152. data/test/backend/agent_test.rb +0 -80
  153. data/test/backend/gc_snapshot_test.rb +0 -11
  154. data/test/backend/host_agent_activation_observer_test.rb +0 -73
  155. data/test/backend/host_agent_lookup_test.rb +0 -78
  156. data/test/backend/host_agent_reporting_observer_test.rb +0 -276
  157. data/test/backend/host_agent_test.rb +0 -89
  158. data/test/backend/process_info_test.rb +0 -83
  159. data/test/backend/request_client_test.rb +0 -39
  160. data/test/backend/serverless_agent_test.rb +0 -83
  161. data/test/benchmarks/bench_id_generation.rb +0 -15
  162. data/test/benchmarks/bench_opentracing.rb +0 -16
  163. data/test/config_test.rb +0 -34
  164. data/test/frameworks/cuba_test.rb +0 -61
  165. data/test/frameworks/roda_test.rb +0 -60
  166. data/test/frameworks/sinatra_test.rb +0 -71
  167. data/test/instana_test.rb +0 -37
  168. data/test/instrumentation/aws_test.rb +0 -241
  169. data/test/instrumentation/dalli_test.rb +0 -325
  170. data/test/instrumentation/excon_test.rb +0 -204
  171. data/test/instrumentation/graphql_test.rb +0 -289
  172. data/test/instrumentation/grpc_test.rb +0 -420
  173. data/test/instrumentation/mongo_test.rb +0 -68
  174. data/test/instrumentation/net_http_test.rb +0 -220
  175. data/test/instrumentation/rack_instrumented_request_test.rb +0 -211
  176. data/test/instrumentation/rack_test.rb +0 -415
  177. data/test/instrumentation/rails_action_cable_test.rb +0 -135
  178. data/test/instrumentation/rails_action_controller_test.rb +0 -218
  179. data/test/instrumentation/rails_action_mailer_test.rb +0 -66
  180. data/test/instrumentation/rails_action_view_test.rb +0 -154
  181. data/test/instrumentation/rails_active_job_test.rb +0 -65
  182. data/test/instrumentation/rails_active_record_database_missing_test.rb +0 -45
  183. data/test/instrumentation/rails_active_record_test.rb +0 -115
  184. data/test/instrumentation/redis_test.rb +0 -152
  185. data/test/instrumentation/resque_test.rb +0 -188
  186. data/test/instrumentation/rest_client_test.rb +0 -107
  187. data/test/instrumentation/sequel_test.rb +0 -105
  188. data/test/instrumentation/shoryuken_test.rb +0 -47
  189. data/test/instrumentation/sidekiq-client_test.rb +0 -169
  190. data/test/instrumentation/sidekiq-worker_test.rb +0 -180
  191. data/test/secrets_test.rb +0 -112
  192. data/test/serverless_test.rb +0 -369
  193. data/test/snapshot/deltable_test.rb +0 -17
  194. data/test/snapshot/docker_container_test.rb +0 -82
  195. data/test/snapshot/fargate_container_test.rb +0 -82
  196. data/test/snapshot/fargate_process_test.rb +0 -35
  197. data/test/snapshot/fargate_task_test.rb +0 -49
  198. data/test/snapshot/google_cloud_run_instance_test.rb +0 -74
  199. data/test/snapshot/google_cloud_run_process_test.rb +0 -33
  200. data/test/snapshot/lambda_function_test.rb +0 -37
  201. data/test/snapshot/ruby_process_test.rb +0 -32
  202. data/test/support/apps/active_record/active_record.rb +0 -24
  203. data/test/support/apps/grpc/boot.rb +0 -23
  204. data/test/support/apps/grpc/grpc_server.rb +0 -84
  205. data/test/support/apps/http_endpoint/boot.rb +0 -28
  206. data/test/support/apps/rails/boot.rb +0 -219
  207. data/test/support/apps/rails/models/block.rb +0 -21
  208. data/test/support/apps/rails/models/block6.rb +0 -21
  209. data/test/support/apps/resque/boot.rb +0 -5
  210. data/test/support/apps/resque/jobs/resque_error_job.rb +0 -22
  211. data/test/support/apps/resque/jobs/resque_fast_job.rb +0 -23
  212. data/test/support/apps/sidekiq/boot.rb +0 -25
  213. data/test/support/apps/sidekiq/jobs/sidekiq_job_1.rb +0 -9
  214. data/test/support/apps/sidekiq/jobs/sidekiq_job_2.rb +0 -10
  215. data/test/support/apps/sidekiq/worker.rb +0 -37
  216. data/test/support/helpers.rb +0 -85
  217. data/test/support/mock_timer.rb +0 -20
  218. data/test/test_helper.rb +0 -69
  219. data/test/tracing/custom_test.rb +0 -226
  220. data/test/tracing/id_management_test.rb +0 -80
  221. data/test/tracing/instrumented_logger_test.rb +0 -39
  222. data/test/tracing/opentracing_test.rb +0 -382
  223. data/test/tracing/processor_test.rb +0 -58
  224. data/test/tracing/span_context_test.rb +0 -22
  225. data/test/tracing/span_test.rb +0 -179
  226. data/test/tracing/tracer_async_test.rb +0 -230
  227. data/test/tracing/tracer_test.rb +0 -352
  228. data/test/util_test.rb +0 -10
@@ -1,74 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require 'test_helper'
5
-
6
- class GoogleCloudRunInstanceTest < Minitest::Test
7
- def test_snapshot
8
- ENV['K_SERVICE'] = 'test_service'
9
- ENV['K_CONFIGURATION'] = 'test_config'
10
- ENV['K_REVISION'] = 'test_revision'
11
- ENV['PORT'] = 'test_port'
12
-
13
- stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
14
- .to_return(status: 200, body: 'test_instance_id')
15
- stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/zone')
16
- .to_return(status: 200, body: 'region/number/test_region')
17
- stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/project/numeric-project-id')
18
- .to_return(status: 200, body: 'numericProjectId')
19
- stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/project/project-id')
20
- .to_return(status: 200, body: 'projectId')
21
-
22
- subject = Instana::Snapshot::GoogleCloudRunInstance.new(metadata_uri: 'http://10.10.10.10/')
23
- snapshot = subject.snapshot
24
-
25
- assert_equal Instana::Snapshot::GoogleCloudRunInstance::ID, snapshot[:name]
26
- assert_equal 'test_instance_id', snapshot[:entityId]
27
-
28
- assert_equal "ruby", snapshot[:data][:runtime]
29
- assert_equal "test_region", snapshot[:data][:region]
30
- assert_equal "test_service", snapshot[:data][:service]
31
- assert_equal "test_config", snapshot[:data][:configuration]
32
- assert_equal "test_revision", snapshot[:data][:revision]
33
- assert_equal "test_instance_id", snapshot[:data][:instanceId]
34
- assert_equal "test_port", snapshot[:data][:port]
35
- assert_equal "numericProjectId", snapshot[:data][:numericProjectId]
36
- assert_equal "projectId", snapshot[:data][:projectId]
37
- ensure
38
- ENV['K_SERVICE'] = nil
39
- ENV['K_CONFIGURATION'] = nil
40
- ENV['K_REVISION'] = nil
41
- ENV['PORT'] = nil
42
- end
43
-
44
- def test_snapshot_error
45
- stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
46
- .to_return(status: 500)
47
-
48
- subject = Instana::Snapshot::GoogleCloudRunInstance.new(metadata_uri: 'http://10.10.10.10/')
49
-
50
- assert_raises do
51
- subject.snapshot
52
- end
53
- end
54
-
55
- def test_source
56
- stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
57
- .to_return(status: 200, body: 'test_instance_id')
58
- subject = Instana::Snapshot::GoogleCloudRunInstance.new(metadata_uri: 'http://10.10.10.10/')
59
- source = subject.source
60
-
61
- assert source[:hl]
62
- assert_equal 'gcp', source[:cp]
63
- assert_equal 'test_instance_id', source[:e]
64
- end
65
-
66
- def test_host_name
67
- ENV['K_REVISION'] = 'test_revision'
68
- subject = Instana::Snapshot::GoogleCloudRunInstance.new(metadata_uri: 'http://10.10.10.10/')
69
-
70
- assert_equal 'gcp:cloud-run:revision:test_revision', subject.host_name
71
- ensure
72
- ENV['K_REVISION'] = nil
73
- end
74
- end
@@ -1,33 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require 'test_helper'
5
-
6
- class GoogleCloudRunProcessTest < Minitest::Test
7
- def test_snapshot
8
- ENV['K_REVISION'] = 'test'
9
- stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
10
- .to_return(status: 200, body: 'test_instance_id')
11
-
12
- subject = Instana::Snapshot::GoogleCloudRunProcess.new(metadata_uri: 'http://10.10.10.10/')
13
- snapshot = subject.snapshot
14
-
15
- assert_equal Instana::Snapshot::GoogleCloudRunProcess::ID, snapshot[:name]
16
- assert_equal 'test_instance_id', snapshot[:data][:container]
17
- assert_equal 'gcpCloudRunInstance', snapshot[:data][:containerType]
18
- assert_equal 'gcp:cloud-run:revision:test', snapshot[:data][:'com.instana.plugin.host.name']
19
- ensure
20
- ENV['K_REVISION'] = nil
21
- end
22
-
23
- def test_snapshot_error
24
- stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
25
- .to_return(status: 500)
26
-
27
- subject = Instana::Snapshot::GoogleCloudRunProcess.new(metadata_uri: 'http://10.10.10.10/')
28
-
29
- assert_raises do
30
- subject.snapshot
31
- end
32
- end
33
- end
@@ -1,37 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require 'test_helper'
5
-
6
- class LambdaFunctionTest < Minitest::Test
7
- def setup
8
- @subject = Instana::Snapshot::LambdaFunction.new
9
- end
10
-
11
- def test_snapshot
12
- Thread.current[:instana_function_arn] = 'test'
13
-
14
- assert_equal Instana::Snapshot::LambdaFunction::ID, @subject.snapshot[:name]
15
- assert_equal Thread.current[:instana_function_arn], @subject.snapshot[:entityId]
16
- ensure
17
- Thread.current[:instana_function_arn] = nil
18
- end
19
-
20
- def test_source
21
- Thread.current[:instana_function_arn] = 'test'
22
-
23
- assert @subject.source[:hl]
24
- assert_equal 'aws', @subject.source[:cp]
25
- assert_equal Thread.current[:instana_function_arn], @subject.source[:e]
26
- ensure
27
- Thread.current[:instana_function_arn] = nil
28
- end
29
-
30
- def test_host_name
31
- Thread.current[:instana_function_arn] = 'test'
32
-
33
- assert_equal Thread.current[:instana_function_arn], @subject.host_name
34
- ensure
35
- Thread.current[:instana_function_arn] = nil
36
- end
37
- end
@@ -1,32 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require 'test_helper'
5
-
6
- class RubyProcessTest < Minitest::Test
7
- def test_snapshot
8
- subject = Instana::Snapshot::RubyProcess.new
9
- snapshot = subject.snapshot
10
-
11
- assert_equal Instana::Snapshot::RubyProcess::ID, snapshot[:name]
12
- assert_equal Process.pid.to_s, snapshot[:entityId]
13
- assert_equal File.basename($PROGRAM_NAME), snapshot[:data][:name]
14
- end
15
-
16
- def test_snapshot_with_rails_defined_but_no_rails_application
17
- Object.send(:const_set, :Rails,
18
- Module.new do
19
- def respond_to?
20
- false
21
- end
22
- end)
23
- subject = Instana::Snapshot::RubyProcess.new
24
- snapshot = subject.snapshot
25
-
26
- assert_equal Instana::Snapshot::RubyProcess::ID, snapshot[:name]
27
- assert_equal Process.pid.to_s, snapshot[:entityId]
28
- assert_equal File.basename($PROGRAM_NAME), snapshot[:data][:name]
29
- ensure
30
- Object.send(:remove_const, :Rails)
31
- end
32
- end
@@ -1,24 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require 'rails'
5
- require 'active_record/railtie'
6
-
7
- migration_class = if ActiveRecord::Migration.respond_to?(:[])
8
- ActiveRecord::Migration[4.2]
9
- else
10
- ActiveRecord::Migration
11
- end
12
-
13
- class CreateBlocks < migration_class
14
- def change
15
- create_table :blocks do |t|
16
- t.string :name
17
- t.string :color
18
- t.timestamps
19
- end
20
- end
21
- end
22
-
23
- class Block < ActiveRecord::Base
24
- end
@@ -1,23 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2017
3
-
4
- require_relative 'grpc_server'
5
-
6
- ::Instana.logger.info "Booting instrumented gRPC server on port 50051 for tests."
7
-
8
- grpc_thread = Thread.new do
9
- s = GRPC::RpcServer.new
10
- Thread.current[:server] = s
11
-
12
- s.add_http2_port('127.0.0.1:50051', :this_port_is_insecure)
13
- s.handle(PingPongServer)
14
- s.run_till_terminated
15
- end
16
-
17
- Minitest.after_run do
18
- ::Instana.logger.info "Killing gRPC server"
19
- grpc_thread[:server].stop
20
- sleep 2
21
- end
22
-
23
- sleep 2
@@ -1,84 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2017
3
-
4
- require 'google/protobuf'
5
-
6
- Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_message "PingPongService.PingRequest" do
8
- optional :message, :string, 1
9
- end
10
- add_message "PingPongService.PongReply" do
11
- optional :message, :string, 1
12
- end
13
- end
14
-
15
- module PingPongService
16
- PingRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("PingPongService.PingRequest").msgclass
17
- PongReply = Google::Protobuf::DescriptorPool.generated_pool.lookup("PingPongService.PongReply").msgclass
18
- end
19
- require 'grpc'
20
-
21
- module PingPongService
22
- # The greeting service definition.
23
- class Service
24
- include GRPC::GenericService
25
-
26
- self.marshal_class_method = :encode
27
- self.unmarshal_class_method = :decode
28
- self.service_name = 'PingPongService'
29
-
30
- rpc :Ping, PingRequest, PongReply
31
- rpc :PingWithClientStream, stream(PingRequest), PongReply
32
- rpc :PingWithServerStream, PingRequest, stream(PongReply)
33
- rpc :PingWithBidiStream, stream(PingRequest), stream(PongReply)
34
-
35
- rpc :FailToPing, PingRequest, PongReply
36
- rpc :FailToPingWithClientStream, stream(PingRequest), PongReply
37
- rpc :FailToPingWithServerStream, PingRequest, stream(PongReply)
38
- rpc :FailToPingWithBidiStream, stream(PingRequest), stream(PongReply)
39
- end
40
-
41
- Stub = Service.rpc_stub_class
42
- end
43
-
44
- class PingPongServer < PingPongService::Service
45
- def ping(ping_request, active_call)
46
- PingPongService::PongReply.new(message: "Hello #{ping_request.message}")
47
- end
48
-
49
- def ping_with_client_stream(active_call)
50
- message = ''
51
- active_call.each_remote_read do |req|
52
- message += req.message
53
- end
54
- PingPongService::PongReply.new(message: message)
55
- end
56
-
57
- def ping_with_server_stream(ping_request, active_call)
58
- (0..5).map do |index|
59
- PingPongService::PongReply.new(message: index.to_s)
60
- end
61
- end
62
-
63
- def ping_with_bidi_stream(ping_requests)
64
- ping_requests.map do |ping_request|
65
- PingPongService::PongReply.new(message: ping_request.message)
66
- end
67
- end
68
-
69
- def fail_to_ping(ping_request, active_call)
70
- raise 'Unexpected failed'
71
- end
72
-
73
- def fail_to_ping_with_client_stream(active_call)
74
- raise 'Unexpected failed'
75
- end
76
-
77
- def fail_to_ping_with_server_stream(ping_request, active_call)
78
- raise 'Unexpected failed'
79
- end
80
-
81
- def fail_to_ping_with_bidi_stream(ping_requests)
82
- raise 'Unexpected failed'
83
- end
84
- end
@@ -1,28 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2016
3
-
4
- require 'rack/handler/puma'
5
- require 'rack/builder'
6
- require 'instana/rack'
7
-
8
- ::Instana.logger.info "Booting instrumented background Rackapp on port 6511 for tests."
9
-
10
- Thread.new do
11
- app = Rack::Builder.new {
12
- use ::Instana::Rack
13
- map "/" do
14
- run Proc.new { |env|
15
- [200, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"scene!\"]"]]
16
- }
17
- end
18
- map "/error" do
19
- run Proc.new { |env|
20
- [500, {"Content-Type" => "application/json"}, ["[\"Stan\",\"is\",\"on\",\"the\",\"error!\"]"]]
21
- }
22
- end
23
- }
24
-
25
- Rackup::Handler::Puma.run(app, Host: '127.0.0.1', Port: 6511)
26
- end
27
-
28
- sleep(2)
@@ -1,219 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2017
3
-
4
- ::Instana.logger.warn "Starting background Ruby on Rails #{Rails::VERSION::STRING} application on port 3205"
5
-
6
- require "rails"
7
- require "active_record/railtie"
8
- require "active_model/railtie"
9
- require "action_controller/railtie"
10
- require "active_model/railtie"
11
- require 'rack/handler/puma'
12
-
13
- if Rails::VERSION::STRING >= '6.0'
14
- require_relative 'models/block6'
15
- else
16
- require_relative 'models/block'
17
- end
18
-
19
- ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
20
-
21
- unless ActiveRecord::Base.connection.table_exists? 'blocks'
22
- if Rails::VERSION::STRING < '4.0'
23
- CreateBlocks.migrate(:up)
24
- else
25
- ActiveRecord::Migration.run(CreateBlocks)
26
- end
27
- end
28
-
29
- class RailsTestApp < Rails::Application
30
- routes.append do
31
- get "/test/world" => "test#world"
32
- get "/test/db" => "test#db"
33
- get "/test/db_lock_table" => "test#db_lock_table"
34
- get "/test/db_raw_execute" => "test#db_raw_execute"
35
- get "/test/db_raw_execute_error" => "test#db_raw_execute_error"
36
- get "/test/error" => "test#error"
37
- get "/test/render_view" => "test#render_view"
38
- get "/test/render_partial" => "test#render_partial"
39
- get "/test/render_collection" => "test#render_collection"
40
- get "/test/render_file" => "test#render_file"
41
- get "/test/render_nothing" => "test#render_nothing"
42
- get "/test/render_json" => "test#render_json"
43
- get "/test/render_xml" => "test#render_xml"
44
- get "/test/render_rawbody" => "test#render_rawbody"
45
- get "/test/render_js" => "test#render_js"
46
- get "/test/render_alternate_layout" => "test#render_alternate_layout"
47
- get "/test/render_partial_that_errors" => "test#render_partial_that_errors"
48
- get "/test/raise_route_error" => "test#raise_route_error"
49
-
50
- get "/api/world" => "socket#world"
51
- get "/api/error" => "socket#error"
52
- get "/api/raise_route_error" => "socket#raise_route_error"
53
- end
54
-
55
- # Enable cache classes. Production style.
56
- config.cache_classes = true
57
- config.eager_load = false
58
-
59
- # uncomment below to display errors
60
- # config.consider_all_requests_local = true
61
-
62
- config.paths['app/views'].unshift(File.join(__dir__, 'views'))
63
-
64
- config.active_support.deprecation = :stderr
65
-
66
- config.middleware.delete Rack::Lock
67
- config.middleware.delete ActionDispatch::Flash
68
-
69
- # We need a secret token for session, cookies, etc.
70
- config.secret_token = "doesntneedtobesecurefortests"
71
- config.secret_key_base = "blueredaquarossoseven"
72
- end
73
-
74
- class TestController < ActionController::Base
75
- def world
76
- if ::Rails::VERSION::MAJOR > 4
77
- render :plain => "Hello test world!"
78
- else
79
- render :text => "Hello test world!"
80
- end
81
- end
82
-
83
- def db
84
- white_block = Block.new(:name => 'Part #28349', :color => 'White')
85
- white_block.save
86
- found = Block.where(:name => 'Part #28349').first
87
- found.delete
88
-
89
- if ::Rails::VERSION::MAJOR > 4
90
- render :plain => "Hello test db!"
91
- else
92
- render :text => "Hello test db!"
93
- end
94
- end
95
-
96
- def db_raw_execute
97
- ActiveRecord::Base.connection.execute("SELECT 1")
98
-
99
- if ::Rails::VERSION::MAJOR > 4
100
- render :plain => "Hello test db!"
101
- else
102
- render :text => "Hello test db!"
103
- end
104
- end
105
-
106
- def db_raw_execute_error
107
- ActiveRecord::Base.connection.execute("This is not real SQL but an intended error")
108
-
109
- if ::Rails::VERSION::MAJOR > 4
110
- render :plain => "Hello test db!"
111
- else
112
- render :text => "Hello test db!"
113
- end
114
- end
115
-
116
- def db_lock_table
117
- ActiveRecord::Base.transaction do
118
- ActiveRecord::Base.connection.execute('LOCK blocks IN ACCESS EXCLUSIVE MODE')
119
- ActiveRecord::Base.connection.execute("SELECT 1")
120
- end
121
-
122
- if ::Rails::VERSION::MAJOR > 4
123
- render :plain => "Hello test db!"
124
- else
125
- render :text => "Hello test db!"
126
- end
127
- end
128
-
129
- def render_view
130
- @message = "Hello Instana!"
131
- end
132
-
133
- def render_partial
134
- @message = "Hello Instana!"
135
- end
136
-
137
- def render_partial_that_errors
138
- @message = "Hello Instana!"
139
- end
140
-
141
- def render_collection
142
- @blocks = Block.all
143
- end
144
-
145
- def render_file
146
- @message = "Hello Instana!"
147
- render :file => '/etc/issue'
148
- end
149
-
150
- def render_alternate_layout
151
- @message = "Hello Instana!"
152
- render :layout => 'layouts/mobile'
153
- end
154
-
155
- def render_nothing
156
- @message = "Hello Instana!"
157
- render :nothing => true
158
- end
159
-
160
- def render_json
161
- @message = "Hello Instana!"
162
- render :json => @message
163
- end
164
-
165
- def render_xml
166
- @message = "Hello Instana!"
167
- render :xml => @message
168
- end
169
-
170
- def render_rawbody
171
- @message = "Hello Instana!"
172
- render :body => 'raw body output'
173
- end
174
-
175
- def render_js
176
- @message = "Hello Instana!"
177
- render :js => @message
178
- end
179
-
180
- def error
181
- raise Exception.new("Warning: This is a simulated Error")
182
- end
183
-
184
- def raise_route_error
185
- raise ActionController::RoutingError.new('Simulated not found')
186
- end
187
- end
188
-
189
- if ::Rails::VERSION::MAJOR > 4
190
- class SocketController < ActionController::API
191
- def world
192
- if ::Rails::VERSION::MAJOR > 4
193
- render :plain => "Hello api world!"
194
- else
195
- render :text => "Hello api world!"
196
- end
197
- end
198
-
199
- def raise_route_error
200
- raise ActionController::RoutingError.new('Simulated not found')
201
- end
202
-
203
- def error
204
- raise Exception.new("Warning: This is a simulated Socket API Error")
205
- end
206
- end
207
- end
208
-
209
- RailsTestApp.initialize!
210
-
211
- # Initialize some blocks so we have stuff to test against.
212
- Block.new(:name => :corner, :color => :blue).save
213
- Block.new(:name => :floor, :color => :green).save
214
-
215
- Thread.new do
216
- Rack::Handler::Puma.run(RailsTestApp.to_app, {:Host => '127.0.0.1', :Port => 3205})
217
- end
218
-
219
- sleep(1)
@@ -1,21 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2017
3
-
4
- class Block < ActiveRecord::Base
5
- def do_work(*args)
6
- block = Block.first
7
- block.name = "Charlie"
8
- block.color = "Black"
9
- block.save
10
- end
11
- end
12
-
13
- class CreateBlocks < ActiveRecord::Migration[4.2]
14
- def change
15
- create_table :blocks do |t|
16
- t.string :name
17
- t.string :color
18
- t.timestamps
19
- end
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2017
3
-
4
- class Block < ActiveRecord::Base
5
- def do_work(*args)
6
- block = Block.first
7
- block.name = "Charlie"
8
- block.color = "Black"
9
- block.save
10
- end
11
- end
12
-
13
- class CreateBlocks < ActiveRecord::Migration[6.0]
14
- def change
15
- create_table :blocks do |t|
16
- t.string :name
17
- t.string :color
18
- t.timestamps
19
- end
20
- end
21
- end
@@ -1,5 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require_relative 'jobs/resque_error_job'
5
- require_relative 'jobs/resque_fast_job'
@@ -1,22 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2018
3
-
4
- require "redis"
5
- require "net/http"
6
-
7
- class ErrorJob
8
- @queue = :critical
9
-
10
- def self.perform
11
- if ENV.key?('REDIS_URL')
12
- redis = Redis.new(:url => ENV['REDIS_URL'])
13
- else
14
- redis = Redis.new(:url => 'redis://localhost:6379')
15
- end
16
-
17
- dt = Time.now
18
- redis.set('ts', dt)
19
-
20
- raise Exception.new("Silly Rabbit, Trix are for kids.")
21
- end
22
- end
@@ -1,23 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2018
3
-
4
- require "redis"
5
- require "net/http"
6
-
7
- class FastJob
8
- @queue = :critical
9
-
10
- def self.perform(*args)
11
- raise 'Invalid Args' unless args.empty?
12
-
13
- if ENV.key?('REDIS_URL')
14
- redis = Redis.new(:url => ENV['REDIS_URL'])
15
- else
16
- redis = Redis.new(:url => 'redis://localhost:6379')
17
- end
18
-
19
- dt = Time.now
20
- redis.set('ts', dt)
21
- redis.set(:nb_id, 2)
22
- end
23
- end
@@ -1,25 +0,0 @@
1
- # Hook into sidekiq to control the current mode
2
-
3
- # (c) Copyright IBM Corp. 2021
4
- # (c) Copyright Instana Inc. 2021
5
-
6
- $sidekiq_mode = :client
7
- class << Sidekiq
8
- def server?
9
- $sidekiq_mode == :server
10
- end
11
- end
12
-
13
- # Configure redis for sidekiq client
14
- Sidekiq.configure_client do |config|
15
- config.redis = { url: ENV['REDIS_URL'] }
16
- end
17
-
18
- # Configure redis for sidekiq worker
19
- $sidekiq_mode = :server
20
- ::Sidekiq.configure_server do |config|
21
- config.redis = { url: ENV['REDIS_URL'] }
22
- end
23
- $sidekiq_mode = :client
24
-
25
- require_relative 'worker'