skywalking 0.0.0.alpha → 0.0.0.beta1

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 (161) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +19 -0
  3. data/.github/PULL_REQUEST_TEMPLATE +42 -0
  4. data/.github/workflows/ci.yml +70 -0
  5. data/.github/workflows/e2e.yml +73 -0
  6. data/.gitignore +80 -0
  7. data/.gitmodules +18 -0
  8. data/.licenserc.yaml +36 -0
  9. data/.rspec +1 -2
  10. data/.rubocop.yml +6 -0
  11. data/CHANGELOG.md +3 -0
  12. data/Gemfile +20 -0
  13. data/NOTICE +1 -1
  14. data/docs/README.md +7 -0
  15. data/docs/en/agent/plugins.md +10 -0
  16. data/docs/{How-to-release.md → en/development-and-contribution/how-to-release.md} +6 -5
  17. data/docs/en/setup/quick-start.md +106 -0
  18. data/docs/menu.yml +31 -0
  19. data/lib/rails/generators/skywalking/start_generator.rb +47 -0
  20. data/{examples/rails-demo/config/initializers/skywalking_ruby.rb → lib/rails/generators/skywalking/templates/skywalking_initializer.rb} +0 -2
  21. data/lib/skywalking/agent.rb +5 -5
  22. data/lib/skywalking/configuration.rb +54 -33
  23. data/lib/skywalking/environment.rb +103 -11
  24. data/lib/skywalking/log/logger.rb +1 -1
  25. data/lib/skywalking/plugins/net_http.rb +73 -0
  26. data/lib/skywalking/plugins/redis5.rb +3 -2
  27. data/lib/skywalking/plugins/sinatra.rb +2 -2
  28. data/lib/skywalking/reporter/buffer_trigger.rb +1 -1
  29. data/lib/skywalking/reporter/client/grpc_client.rb +2 -2
  30. data/lib/skywalking/reporter/report.rb +1 -1
  31. data/lib/skywalking/tracing/carrier.rb +9 -8
  32. data/lib/skywalking/tracing/constants.rb +11 -18
  33. data/lib/skywalking/tracing/exit_span.rb +1 -1
  34. data/lib/skywalking/tracing/noop_span.rb +1 -1
  35. data/lib/skywalking/tracing/span.rb +1 -1
  36. data/lib/skywalking/tracing/span_context.rb +4 -4
  37. data/lib/skywalking/tracing/tag.rb +36 -1
  38. data/lib/skywalking/version.rb +1 -1
  39. data/skywalking.gemspec +61 -0
  40. data/spec/fixtures/agent.yaml +33 -0
  41. data/spec/scenarios/common/Dockerfile.agent +26 -0
  42. data/spec/scenarios/common/base-compose.yml +46 -0
  43. data/spec/scenarios/common/common_spec_helper.rb +40 -0
  44. data/spec/scenarios/common/compose_context.rb +39 -0
  45. data/spec/scenarios/common/validator.rb +41 -0
  46. data/spec/scenarios/net_http/docker-compose.yml +49 -0
  47. data/spec/scenarios/net_http/expected.yml +39 -0
  48. data/spec/scenarios/net_http/net_http.rb +33 -0
  49. data/spec/scenarios/net_http/net_http_spec.rb +43 -0
  50. data/spec/scenarios/redis/docker-compose.yml +67 -0
  51. data/spec/scenarios/redis/expected.yml +66 -0
  52. data/{examples/sinatra-demo/sinatra-demo.rb → spec/scenarios/redis/redis.rb} +8 -10
  53. data/spec/scenarios/redis/redis_spec.rb +29 -0
  54. data/spec/scenarios/sinatra/docker-compose.yml +54 -0
  55. data/spec/scenarios/sinatra/expected.yml +38 -0
  56. data/spec/scenarios/sinatra/sinatra.rb +26 -0
  57. data/spec/scenarios/sinatra/sinatra_spec.rb +29 -0
  58. data/spec/skywalking/config_spec.rb +41 -0
  59. data/spec/skywalking/utils/id_gen_spec.rb +26 -0
  60. data/spec/spec_helper.rb +115 -0
  61. metadata +134 -143
  62. data/examples/rails-demo/.dockerignore +0 -47
  63. data/examples/rails-demo/.gitattributes +0 -9
  64. data/examples/rails-demo/.gitignore +0 -34
  65. data/examples/rails-demo/.kamal/hooks/docker-setup.sample +0 -3
  66. data/examples/rails-demo/.kamal/hooks/post-deploy.sample +0 -14
  67. data/examples/rails-demo/.kamal/hooks/post-proxy-reboot.sample +0 -3
  68. data/examples/rails-demo/.kamal/hooks/pre-build.sample +0 -51
  69. data/examples/rails-demo/.kamal/hooks/pre-connect.sample +0 -47
  70. data/examples/rails-demo/.kamal/hooks/pre-deploy.sample +0 -109
  71. data/examples/rails-demo/.kamal/hooks/pre-proxy-reboot.sample +0 -3
  72. data/examples/rails-demo/.kamal/secrets +0 -17
  73. data/examples/rails-demo/.rubocop.yml +0 -8
  74. data/examples/rails-demo/.ruby-version +0 -1
  75. data/examples/rails-demo/Dockerfile +0 -72
  76. data/examples/rails-demo/Gemfile +0 -64
  77. data/examples/rails-demo/README.md +0 -24
  78. data/examples/rails-demo/Rakefile +0 -6
  79. data/examples/rails-demo/app/assets/images/.keep +0 -0
  80. data/examples/rails-demo/app/assets/stylesheets/application.css +0 -10
  81. data/examples/rails-demo/app/controllers/application_controller.rb +0 -4
  82. data/examples/rails-demo/app/controllers/concerns/.keep +0 -0
  83. data/examples/rails-demo/app/helpers/application_helper.rb +0 -2
  84. data/examples/rails-demo/app/javascript/application.js +0 -3
  85. data/examples/rails-demo/app/javascript/controllers/application.js +0 -9
  86. data/examples/rails-demo/app/javascript/controllers/hello_controller.js +0 -7
  87. data/examples/rails-demo/app/javascript/controllers/index.js +0 -4
  88. data/examples/rails-demo/app/jobs/application_job.rb +0 -7
  89. data/examples/rails-demo/app/mailers/application_mailer.rb +0 -4
  90. data/examples/rails-demo/app/models/application_record.rb +0 -3
  91. data/examples/rails-demo/app/models/concerns/.keep +0 -0
  92. data/examples/rails-demo/app/views/layouts/application.html.erb +0 -28
  93. data/examples/rails-demo/app/views/layouts/mailer.html.erb +0 -13
  94. data/examples/rails-demo/app/views/layouts/mailer.text.erb +0 -1
  95. data/examples/rails-demo/app/views/pwa/manifest.json.erb +0 -22
  96. data/examples/rails-demo/app/views/pwa/service-worker.js +0 -26
  97. data/examples/rails-demo/bin/brakeman +0 -7
  98. data/examples/rails-demo/bin/bundle +0 -109
  99. data/examples/rails-demo/bin/dev +0 -2
  100. data/examples/rails-demo/bin/docker-entrypoint +0 -14
  101. data/examples/rails-demo/bin/importmap +0 -4
  102. data/examples/rails-demo/bin/jobs +0 -6
  103. data/examples/rails-demo/bin/kamal +0 -27
  104. data/examples/rails-demo/bin/rails +0 -4
  105. data/examples/rails-demo/bin/rake +0 -4
  106. data/examples/rails-demo/bin/rubocop +0 -8
  107. data/examples/rails-demo/bin/setup +0 -34
  108. data/examples/rails-demo/bin/thrust +0 -5
  109. data/examples/rails-demo/config/application.rb +0 -27
  110. data/examples/rails-demo/config/boot.rb +0 -4
  111. data/examples/rails-demo/config/cable.yml +0 -17
  112. data/examples/rails-demo/config/cache.yml +0 -16
  113. data/examples/rails-demo/config/credentials.yml.enc +0 -1
  114. data/examples/rails-demo/config/database.yml +0 -41
  115. data/examples/rails-demo/config/deploy.yml +0 -116
  116. data/examples/rails-demo/config/environment.rb +0 -5
  117. data/examples/rails-demo/config/environments/development.rb +0 -72
  118. data/examples/rails-demo/config/environments/production.rb +0 -90
  119. data/examples/rails-demo/config/environments/test.rb +0 -53
  120. data/examples/rails-demo/config/importmap.rb +0 -7
  121. data/examples/rails-demo/config/initializers/assets.rb +0 -7
  122. data/examples/rails-demo/config/initializers/content_security_policy.rb +0 -25
  123. data/examples/rails-demo/config/initializers/filter_parameter_logging.rb +0 -8
  124. data/examples/rails-demo/config/initializers/inflections.rb +0 -16
  125. data/examples/rails-demo/config/locales/en.yml +0 -31
  126. data/examples/rails-demo/config/puma.rb +0 -41
  127. data/examples/rails-demo/config/queue.yml +0 -18
  128. data/examples/rails-demo/config/recurring.yml +0 -10
  129. data/examples/rails-demo/config/routes.rb +0 -14
  130. data/examples/rails-demo/config/storage.yml +0 -34
  131. data/examples/rails-demo/config.ru +0 -6
  132. data/examples/rails-demo/db/cable_schema.rb +0 -11
  133. data/examples/rails-demo/db/cache_schema.rb +0 -14
  134. data/examples/rails-demo/db/queue_schema.rb +0 -129
  135. data/examples/rails-demo/db/seeds.rb +0 -9
  136. data/examples/rails-demo/lib/tasks/.keep +0 -0
  137. data/examples/rails-demo/log/.keep +0 -0
  138. data/examples/rails-demo/public/400.html +0 -114
  139. data/examples/rails-demo/public/404.html +0 -114
  140. data/examples/rails-demo/public/406-unsupported-browser.html +0 -114
  141. data/examples/rails-demo/public/422.html +0 -114
  142. data/examples/rails-demo/public/500.html +0 -114
  143. data/examples/rails-demo/public/icon.png +0 -0
  144. data/examples/rails-demo/public/icon.svg +0 -3
  145. data/examples/rails-demo/public/robots.txt +0 -1
  146. data/examples/rails-demo/script/.keep +0 -0
  147. data/examples/rails-demo/storage/.keep +0 -0
  148. data/examples/rails-demo/test/application_system_test_case.rb +0 -5
  149. data/examples/rails-demo/test/controllers/.keep +0 -0
  150. data/examples/rails-demo/test/fixtures/files/.keep +0 -0
  151. data/examples/rails-demo/test/helpers/.keep +0 -0
  152. data/examples/rails-demo/test/integration/.keep +0 -0
  153. data/examples/rails-demo/test/mailers/.keep +0 -0
  154. data/examples/rails-demo/test/models/.keep +0 -0
  155. data/examples/rails-demo/test/system/.keep +0 -0
  156. data/examples/rails-demo/test/test_helper.rb +0 -15
  157. data/examples/rails-demo/tmp/.keep +0 -0
  158. data/examples/rails-demo/tmp/pids/.keep +0 -0
  159. data/examples/rails-demo/tmp/storage/.keep +0 -0
  160. data/examples/rails-demo/vendor/.keep +0 -0
  161. data/examples/rails-demo/vendor/javascript/.keep +0 -0
@@ -31,7 +31,7 @@ module Skywalking
31
31
  @key = 'http.method'
32
32
  end
33
33
  end
34
-
34
+
35
35
  class TagHttpURL < Tag
36
36
  def initialize(val)
37
37
  super
@@ -39,11 +39,46 @@ module Skywalking
39
39
  end
40
40
  end
41
41
 
42
+ class TagHttpStatusCode < Tag
43
+ def initialize(val)
44
+ super
45
+ @key = 'http.status_code'
46
+ end
47
+ end
48
+
42
49
  class TagDbType < Tag
43
50
  def initialize(val)
44
51
  super
45
52
  @key = 'db.type'
46
53
  end
47
54
  end
55
+
56
+ class TagCacheType < Tag
57
+ def initialize(val)
58
+ super
59
+ @key = 'cache.type'
60
+ end
61
+ end
62
+
63
+ class TagCacheOp < Tag
64
+ def initialize(val)
65
+ super
66
+ @key = 'cache.op'
67
+ end
68
+ end
69
+
70
+ class TagCacheCmd < Tag
71
+ def initialize(val)
72
+ super
73
+ @key = 'cache.cmd'
74
+ end
75
+ end
76
+
77
+ class TagCacheKey < Tag
78
+ def initialize(val)
79
+ super
80
+ @key = 'cache.key'
81
+ end
82
+ end
48
83
  end
49
84
  end
@@ -14,5 +14,5 @@
14
14
  # limitations under the License.
15
15
 
16
16
  module Skywalking
17
- VERSION = "0.0.0.alpha".freeze
17
+ VERSION = "0.0.0.beta1".freeze
18
18
  end
@@ -0,0 +1,61 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require File.expand_path('lib/skywalking/version', __dir__)
17
+
18
+ Gem::Specification.new do |spec|
19
+ spec.name = 'skywalking'
20
+ spec.version = Skywalking::VERSION
21
+ spec.authors = ['Apache SkyWalking Team']
22
+ spec.email = ['dev@skywalking.apache.org']
23
+
24
+ spec.summary = 'Skywalking Ruby Agent'
25
+ spec.description = 'The Ruby Agent for Apache SkyWalking'
26
+ spec.homepage = 'https://skywalking.apache.org/'
27
+ spec.license = 'Apache-2.0'
28
+ spec.required_ruby_version = '>= 3.0.0'
29
+
30
+ spec.metadata["homepage_uri"] = spec.homepage
31
+ spec.metadata["source_code_uri"] = 'https://github.com/apache/skywalking-ruby'
32
+ spec.metadata["changelog_uri"] = 'https://github.com/apache/skywalking-ruby/blob/main/CHANGELOG.md'
33
+
34
+ files =
35
+ begin
36
+ `git ls-files`.split("\n")
37
+ rescue StandardError
38
+ Dir.glob("**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
39
+ end
40
+ spec.files = files
41
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
42
+ spec.require_paths = ['lib']
43
+
44
+ # Communication with OAP
45
+ spec.add_dependency 'grpc', '1.68.1'
46
+
47
+ # Base dev dependency
48
+ spec.add_development_dependency 'bundler', '~> 2.0'
49
+ spec.add_development_dependency 'rake', '13.2.1'
50
+ spec.add_development_dependency 'rspec', '~> 3'
51
+ spec.add_development_dependency 'rubocop', '1.69.2'
52
+ spec.add_development_dependency 'rubocop-performance', '1.23.0'
53
+ spec.add_development_dependency 'bigdecimal', '3.1.5'
54
+
55
+ # E2E test dependency
56
+ spec.add_development_dependency 'redis', '~> 5.0'
57
+ spec.add_development_dependency 'sinatra', '~> 4.1'
58
+ spec.add_development_dependency 'testcontainers-compose', '~> 0.2.0'
59
+ spec.add_development_dependency 'faraday', '~> 2.12'
60
+ spec.add_development_dependency 'rspec-wait', '~> 1.0'
61
+ end
@@ -0,0 +1,33 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ common: &defaults
19
+ service_name: Ruby-Agent-Common
20
+ log_level: debug
21
+
22
+ development:
23
+ <<: *defaults
24
+ service_name: Ruby-Agent-Development
25
+
26
+ test:
27
+ <<: *defaults
28
+ service_name: Ruby-Agent-Test
29
+
30
+ production:
31
+ <<: *defaults
32
+ service_name: Ruby-Agent-Production
33
+
@@ -0,0 +1,26 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ ARG SW_RUBY_VERSION
17
+
18
+ FROM ruby:${SW_RUBY_VERSION}
19
+
20
+ ARG ROOT=.
21
+
22
+ WORKDIR /app
23
+
24
+ ADD $ROOT /app
25
+
26
+ RUN bundle
@@ -0,0 +1,46 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ version: '2.1'
19
+
20
+ services:
21
+ oap:
22
+ image: ghcr.io/apache/skywalking-agent-test-tool/mock-collector:b6efe6af0a5499502b8cf8b76c7351e3f172a616
23
+ ports:
24
+ - "12800:12800"
25
+ - "19876:19876"
26
+ networks:
27
+ - gem
28
+ healthcheck:
29
+ test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/12800" ]
30
+ interval: 5s
31
+ timeout: 60s
32
+ retries: 120
33
+
34
+ agent:
35
+ build:
36
+ context: ../../../
37
+ dockerfile: spec/scenarios/common/Dockerfile.agent
38
+ args:
39
+ - SW_RUBY_VERSION=${SW_RUBY_VERSION:-3.0}
40
+ environment:
41
+ SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:19876
42
+ networks:
43
+ - gem
44
+
45
+ networks:
46
+ gem:
@@ -0,0 +1,40 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'testcontainers/compose'
17
+ require 'faraday'
18
+ require_relative 'validator'
19
+
20
+ module CommonSpecHelper
21
+ include Validator
22
+
23
+ def test_plugin(plugin_name)
24
+ p "Now testing #{plugin_name} plugin"
25
+ expected_data = File.read(File.join(root_dir, 'expected.yml'))
26
+
27
+ with_retries do
28
+ resp = Faraday.post(data_validate_url) do |req|
29
+ req.body = expected_data
30
+ req.headers['Content-Type'] = 'application/x-yaml'
31
+ end
32
+ unless resp.status == 200
33
+ actual_data = Faraday.get(receive_data_url).body
34
+ raise "Data validation failed, actual Data: #{actual_data} and cause by: #{resp.body}"
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+
@@ -0,0 +1,39 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ RSpec.shared_context 'scenario value' do
17
+ let(:data_validate_url) { 'http://localhost:12800/dataValidate' }
18
+ let(:receive_data_url) { 'http://localhost:12800/receiveData' }
19
+ end
20
+
21
+ RSpec.shared_context 'compose' do
22
+ let(:client_url) { 'http://localhost:8080/execute' }
23
+
24
+ let(:compose) do
25
+ Testcontainers::ComposeContainer.new(
26
+ filepath: root_dir,
27
+ compose_filenames: ["docker-compose.yml"]
28
+ )
29
+ end
30
+
31
+ before(:each) do
32
+ compose.start
33
+ compose.wait_for_http(url: client_url, timeout: 600)
34
+ end
35
+
36
+ after(:each) do
37
+ compose.stop
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Validator
17
+ def with_retries(retries: 3, backoff_max: 16, backoff_base: 1)
18
+ return if retries < 0
19
+
20
+ backoff ||= 0
21
+
22
+ yield if block_given?
23
+ rescue SystemExit, Interrupt
24
+ raise
25
+ rescue Exception => e
26
+ p e
27
+ if retries.zero?
28
+ p "Retries exhausted"
29
+ raise e
30
+ else
31
+ retries -= 1
32
+ backoff = [backoff == 0 ? 1 : backoff * 2, backoff_max].min
33
+ backoff *= 0.5 * (1 + Kernel.rand)
34
+ backoff = [backoff_base, backoff].max
35
+ p "Retrying in #{backoff} seconds"
36
+
37
+ sleep backoff
38
+ retry
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,49 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ version: "2.1"
19
+
20
+ services:
21
+ oap:
22
+ extends:
23
+ file: ../common/base-compose.yml
24
+ service: oap
25
+ networks:
26
+ - gem
27
+
28
+ service:
29
+ extends:
30
+ file: ../common/base-compose.yml
31
+ service: agent
32
+ ports:
33
+ - "8080:8080"
34
+ volumes:
35
+ - .:/app/spec/scenarios/net_http
36
+ environment:
37
+ SW_AGENT_SERVICE_NAME: "NetHttp"
38
+ entrypoint:
39
+ - "sh"
40
+ - "-c"
41
+ - "ruby /app/spec/scenarios/net_http/net_http.rb"
42
+ depends_on:
43
+ oap:
44
+ condition: service_healthy
45
+ networks:
46
+ - gem
47
+
48
+ networks:
49
+ gem:
@@ -0,0 +1,39 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ segmentItems:
18
+ - serviceName: NetHttp
19
+ segmentSize: ge 1
20
+ segments:
21
+ - segmentId: not null
22
+ spans:
23
+ - operationName: "GET:/json?a=1"
24
+ parentSpanId: -1
25
+ spanId: 0
26
+ spanLayer: Http
27
+ startTime: gt 0
28
+ endTime: gt 0
29
+ componentId: 2
30
+ isError: false
31
+ spanType: Exit
32
+ peer: httpbin.org
33
+ skipAnalysis: false
34
+ tags:
35
+ - { key: http.method, value: GET }
36
+ - { key: http.url, value: "http://httpbin.org/json?a=1" }
37
+ - { key: http.status_code, value: "200" }
38
+ meterItems: [ ]
39
+ logItems: [ ]
@@ -0,0 +1,33 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require_relative '../../../lib/skywalking'
17
+ require 'net/http'
18
+ require 'uri'
19
+ require 'json'
20
+
21
+ Skywalking.start
22
+
23
+ url = URI.parse('http://httpbin.org/json?a=1')
24
+
25
+ response = Net::HTTP.get_response(url)
26
+
27
+ if response.is_a?(Net::HTTPSuccess)
28
+ puts JSON.pretty_generate(JSON.parse(response.body))
29
+ else
30
+ puts "Error..."
31
+ end
32
+
33
+ sleep 10
@@ -0,0 +1,43 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require_relative '../common/common_spec_helper'
17
+ require_relative '../common/compose_context'
18
+
19
+ RSpec.describe 'NetHttp' do
20
+ include CommonSpecHelper
21
+ include_context 'scenario value'
22
+
23
+ let(:root_dir) { File.expand_path(__dir__) }
24
+
25
+ let(:compose) do
26
+ Testcontainers::ComposeContainer.new(
27
+ filepath: root_dir,
28
+ compose_filenames: ["docker-compose.yml"]
29
+ )
30
+ end
31
+
32
+ before(:each) do
33
+ compose.start
34
+ end
35
+
36
+ after(:each) do
37
+ compose.stop
38
+ end
39
+
40
+ it 'test the net_http plugin' do
41
+ test_plugin('net_http')
42
+ end
43
+ end
@@ -0,0 +1,67 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ version: "2.1"
19
+
20
+ services:
21
+ oap:
22
+ extends:
23
+ file: ../common/base-compose.yml
24
+ service: oap
25
+ networks:
26
+ - gem
27
+
28
+ redis:
29
+ image: redis:7-alpine
30
+ hostname: redis
31
+ ports:
32
+ - "6379:6379"
33
+ healthcheck:
34
+ test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6379" ]
35
+ interval: 5s
36
+ timeout: 60s
37
+ retries: 120
38
+ networks:
39
+ - gem
40
+
41
+ service:
42
+ extends:
43
+ file: ../common/base-compose.yml
44
+ service: agent
45
+ ports:
46
+ - "8080:8080"
47
+ volumes:
48
+ - .:/app/spec/scenarios/redis
49
+ environment:
50
+ SW_AGENT_SERVICE_NAME: "redis"
51
+ healthcheck:
52
+ test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/8080" ]
53
+ interval: 5s
54
+ timeout: 60s
55
+ retries: 120
56
+ entrypoint:
57
+ - "sh"
58
+ - "-c"
59
+ - "gem install sinatra rackup puma redis && ruby /app/spec/scenarios/redis/redis.rb"
60
+ depends_on:
61
+ oap:
62
+ condition: service_healthy
63
+ networks:
64
+ - gem
65
+
66
+ networks:
67
+ gem:
@@ -0,0 +1,66 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ segmentItems:
18
+ - serviceName: redis
19
+ segmentSize: ge 1
20
+ segments:
21
+ - segmentId: not null
22
+ spans:
23
+ - operationName: Redis/SET
24
+ parentSpanId: 0
25
+ spanId: 1
26
+ spanLayer: Cache
27
+ startTime: gt 0
28
+ endTime: gt 0
29
+ componentId: 7
30
+ isError: false
31
+ spanType: Exit
32
+ peer: redis:6379
33
+ skipAnalysis: false
34
+ tags:
35
+ - { key: cache.type, value: Redis }
36
+ - { key: cache.op, value: set }
37
+ - operationName: Redis/GET
38
+ parentSpanId: 0
39
+ spanId: 2
40
+ spanLayer: Cache
41
+ startTime: gt 0
42
+ endTime: gt 0
43
+ componentId: 7
44
+ isError: false
45
+ spanType: Exit
46
+ peer: redis:6379
47
+ skipAnalysis: false
48
+ tags:
49
+ - { key: cache.type, value: Redis }
50
+ - { key: cache.op, value: get }
51
+ - operationName: GET:/execute
52
+ parentSpanId: -1
53
+ spanId: 0
54
+ spanLayer: Http
55
+ startTime: gt 0
56
+ endTime: gt 0
57
+ componentId: 12001
58
+ isError: false
59
+ spanType: Entry
60
+ peer: localhost:8080
61
+ skipAnalysis: false
62
+ tags:
63
+ - { key: http.method, value: GET }
64
+ - { key: http.url, value: /execute }
65
+ meterItems: [ ]
66
+ logItems: [ ]
@@ -15,18 +15,16 @@
15
15
 
16
16
  require 'sinatra'
17
17
  require 'redis'
18
+ require_relative '../../../lib/skywalking'
18
19
 
19
- require_relative '../../lib/skywalking'
20
20
  Skywalking.start
21
21
 
22
- get '/sw' do
23
- "Hello, SkyWalking!"
24
- end
25
-
26
- get '/hello/:name' do
27
- redis = Redis.new(host: 'localhost', port: 6379)
22
+ get '/execute' do
23
+ redis = Redis.new(host: 'redis', port: 6379)
28
24
  redis.set('hello', 'world')
29
25
  value = redis.get("hello")
30
- puts "Value of 'hello': #{value}"
31
- "Hello #{params[:name]}!"
32
- end
26
+ "Hello #{value}!"
27
+ end
28
+
29
+ set :bind, '0.0.0.0'
30
+ set :port, 8080