skywalking 0.0.0.alpha → 0.0.0.beta2

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 (174) 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 +4 -0
  12. data/Gemfile +20 -0
  13. data/NOTICE +1 -1
  14. data/README.md +3 -0
  15. data/docs/README.md +7 -0
  16. data/docs/en/agent/plugins.md +12 -0
  17. data/docs/{How-to-release.md → en/development-and-contribution/how-to-release.md} +6 -5
  18. data/docs/en/setup/quick-start.md +106 -0
  19. data/docs/menu.yml +31 -0
  20. data/lib/rails/generators/skywalking/start_generator.rb +47 -0
  21. data/{examples/rails-demo/config/initializers/skywalking_ruby.rb → lib/rails/generators/skywalking/templates/skywalking_initializer.rb} +0 -2
  22. data/lib/skywalking/agent.rb +5 -5
  23. data/lib/skywalking/configuration.rb +55 -34
  24. data/lib/skywalking/environment.rb +103 -11
  25. data/lib/skywalking/log/logger.rb +1 -1
  26. data/lib/skywalking/plugins/elasticsearch.rb +61 -0
  27. data/lib/skywalking/plugins/memcached.rb +74 -0
  28. data/lib/skywalking/plugins/net_http.rb +73 -0
  29. data/lib/skywalking/plugins/redis5.rb +8 -3
  30. data/lib/skywalking/plugins/sinatra.rb +6 -5
  31. data/lib/skywalking/plugins_manager.rb +1 -1
  32. data/lib/skywalking/reporter/buffer_trigger.rb +1 -1
  33. data/lib/skywalking/reporter/client/grpc_client.rb +2 -2
  34. data/lib/skywalking/reporter/report.rb +1 -1
  35. data/lib/skywalking/tracing/carrier.rb +9 -8
  36. data/lib/skywalking/tracing/constants.rb +13 -18
  37. data/lib/skywalking/tracing/exit_span.rb +1 -1
  38. data/lib/skywalking/tracing/noop_span.rb +1 -1
  39. data/lib/skywalking/tracing/segment.rb +1 -1
  40. data/lib/skywalking/tracing/span.rb +2 -1
  41. data/lib/skywalking/tracing/span_context.rb +6 -6
  42. data/lib/skywalking/tracing/tag.rb +50 -1
  43. data/lib/skywalking/version.rb +1 -1
  44. data/skywalking.gemspec +58 -0
  45. data/spec/fixtures/agent.yaml +33 -0
  46. data/spec/scenarios/common/Dockerfile.agent +26 -0
  47. data/spec/scenarios/common/base-compose.yml +46 -0
  48. data/spec/scenarios/common/common_spec_helper.rb +40 -0
  49. data/spec/scenarios/common/compose_context.rb +39 -0
  50. data/spec/scenarios/common/validator.rb +41 -0
  51. data/spec/scenarios/elasticsearch/docker-compose.yml +72 -0
  52. data/spec/scenarios/elasticsearch/elasticsearch.rb +54 -0
  53. data/spec/scenarios/elasticsearch/elasticsearch_spec.rb +29 -0
  54. data/spec/scenarios/elasticsearch/expected.yml +94 -0
  55. data/spec/scenarios/memcached/docker-compose.yml +67 -0
  56. data/spec/scenarios/memcached/expected.yml +81 -0
  57. data/spec/scenarios/memcached/memcached.rb +31 -0
  58. data/spec/scenarios/memcached/memcached_spec.rb +29 -0
  59. data/spec/scenarios/net_http/docker-compose.yml +49 -0
  60. data/spec/scenarios/net_http/expected.yml +39 -0
  61. data/spec/scenarios/net_http/net_http.rb +33 -0
  62. data/spec/scenarios/net_http/net_http_spec.rb +43 -0
  63. data/spec/scenarios/redis/docker-compose.yml +67 -0
  64. data/spec/scenarios/redis/expected.yml +66 -0
  65. data/{examples/sinatra-demo/sinatra-demo.rb → spec/scenarios/redis/redis.rb} +8 -10
  66. data/spec/scenarios/redis/redis_spec.rb +29 -0
  67. data/spec/scenarios/sinatra/docker-compose.yml +54 -0
  68. data/spec/scenarios/sinatra/expected.yml +38 -0
  69. data/spec/scenarios/sinatra/sinatra.rb +26 -0
  70. data/spec/scenarios/sinatra/sinatra_spec.rb +29 -0
  71. data/spec/skywalking/config_spec.rb +41 -0
  72. data/spec/skywalking/utils/id_gen_spec.rb +26 -0
  73. data/spec/spec_helper.rb +115 -0
  74. metadata +102 -143
  75. data/examples/rails-demo/.dockerignore +0 -47
  76. data/examples/rails-demo/.gitattributes +0 -9
  77. data/examples/rails-demo/.gitignore +0 -34
  78. data/examples/rails-demo/.kamal/hooks/docker-setup.sample +0 -3
  79. data/examples/rails-demo/.kamal/hooks/post-deploy.sample +0 -14
  80. data/examples/rails-demo/.kamal/hooks/post-proxy-reboot.sample +0 -3
  81. data/examples/rails-demo/.kamal/hooks/pre-build.sample +0 -51
  82. data/examples/rails-demo/.kamal/hooks/pre-connect.sample +0 -47
  83. data/examples/rails-demo/.kamal/hooks/pre-deploy.sample +0 -109
  84. data/examples/rails-demo/.kamal/hooks/pre-proxy-reboot.sample +0 -3
  85. data/examples/rails-demo/.kamal/secrets +0 -17
  86. data/examples/rails-demo/.rubocop.yml +0 -8
  87. data/examples/rails-demo/.ruby-version +0 -1
  88. data/examples/rails-demo/Dockerfile +0 -72
  89. data/examples/rails-demo/Gemfile +0 -64
  90. data/examples/rails-demo/README.md +0 -24
  91. data/examples/rails-demo/Rakefile +0 -6
  92. data/examples/rails-demo/app/assets/images/.keep +0 -0
  93. data/examples/rails-demo/app/assets/stylesheets/application.css +0 -10
  94. data/examples/rails-demo/app/controllers/application_controller.rb +0 -4
  95. data/examples/rails-demo/app/controllers/concerns/.keep +0 -0
  96. data/examples/rails-demo/app/helpers/application_helper.rb +0 -2
  97. data/examples/rails-demo/app/javascript/application.js +0 -3
  98. data/examples/rails-demo/app/javascript/controllers/application.js +0 -9
  99. data/examples/rails-demo/app/javascript/controllers/hello_controller.js +0 -7
  100. data/examples/rails-demo/app/javascript/controllers/index.js +0 -4
  101. data/examples/rails-demo/app/jobs/application_job.rb +0 -7
  102. data/examples/rails-demo/app/mailers/application_mailer.rb +0 -4
  103. data/examples/rails-demo/app/models/application_record.rb +0 -3
  104. data/examples/rails-demo/app/models/concerns/.keep +0 -0
  105. data/examples/rails-demo/app/views/layouts/application.html.erb +0 -28
  106. data/examples/rails-demo/app/views/layouts/mailer.html.erb +0 -13
  107. data/examples/rails-demo/app/views/layouts/mailer.text.erb +0 -1
  108. data/examples/rails-demo/app/views/pwa/manifest.json.erb +0 -22
  109. data/examples/rails-demo/app/views/pwa/service-worker.js +0 -26
  110. data/examples/rails-demo/bin/brakeman +0 -7
  111. data/examples/rails-demo/bin/bundle +0 -109
  112. data/examples/rails-demo/bin/dev +0 -2
  113. data/examples/rails-demo/bin/docker-entrypoint +0 -14
  114. data/examples/rails-demo/bin/importmap +0 -4
  115. data/examples/rails-demo/bin/jobs +0 -6
  116. data/examples/rails-demo/bin/kamal +0 -27
  117. data/examples/rails-demo/bin/rails +0 -4
  118. data/examples/rails-demo/bin/rake +0 -4
  119. data/examples/rails-demo/bin/rubocop +0 -8
  120. data/examples/rails-demo/bin/setup +0 -34
  121. data/examples/rails-demo/bin/thrust +0 -5
  122. data/examples/rails-demo/config/application.rb +0 -27
  123. data/examples/rails-demo/config/boot.rb +0 -4
  124. data/examples/rails-demo/config/cable.yml +0 -17
  125. data/examples/rails-demo/config/cache.yml +0 -16
  126. data/examples/rails-demo/config/credentials.yml.enc +0 -1
  127. data/examples/rails-demo/config/database.yml +0 -41
  128. data/examples/rails-demo/config/deploy.yml +0 -116
  129. data/examples/rails-demo/config/environment.rb +0 -5
  130. data/examples/rails-demo/config/environments/development.rb +0 -72
  131. data/examples/rails-demo/config/environments/production.rb +0 -90
  132. data/examples/rails-demo/config/environments/test.rb +0 -53
  133. data/examples/rails-demo/config/importmap.rb +0 -7
  134. data/examples/rails-demo/config/initializers/assets.rb +0 -7
  135. data/examples/rails-demo/config/initializers/content_security_policy.rb +0 -25
  136. data/examples/rails-demo/config/initializers/filter_parameter_logging.rb +0 -8
  137. data/examples/rails-demo/config/initializers/inflections.rb +0 -16
  138. data/examples/rails-demo/config/locales/en.yml +0 -31
  139. data/examples/rails-demo/config/puma.rb +0 -41
  140. data/examples/rails-demo/config/queue.yml +0 -18
  141. data/examples/rails-demo/config/recurring.yml +0 -10
  142. data/examples/rails-demo/config/routes.rb +0 -14
  143. data/examples/rails-demo/config/storage.yml +0 -34
  144. data/examples/rails-demo/config.ru +0 -6
  145. data/examples/rails-demo/db/cable_schema.rb +0 -11
  146. data/examples/rails-demo/db/cache_schema.rb +0 -14
  147. data/examples/rails-demo/db/queue_schema.rb +0 -129
  148. data/examples/rails-demo/db/seeds.rb +0 -9
  149. data/examples/rails-demo/lib/tasks/.keep +0 -0
  150. data/examples/rails-demo/log/.keep +0 -0
  151. data/examples/rails-demo/public/400.html +0 -114
  152. data/examples/rails-demo/public/404.html +0 -114
  153. data/examples/rails-demo/public/406-unsupported-browser.html +0 -114
  154. data/examples/rails-demo/public/422.html +0 -114
  155. data/examples/rails-demo/public/500.html +0 -114
  156. data/examples/rails-demo/public/icon.png +0 -0
  157. data/examples/rails-demo/public/icon.svg +0 -3
  158. data/examples/rails-demo/public/robots.txt +0 -1
  159. data/examples/rails-demo/script/.keep +0 -0
  160. data/examples/rails-demo/storage/.keep +0 -0
  161. data/examples/rails-demo/test/application_system_test_case.rb +0 -5
  162. data/examples/rails-demo/test/controllers/.keep +0 -0
  163. data/examples/rails-demo/test/fixtures/files/.keep +0 -0
  164. data/examples/rails-demo/test/helpers/.keep +0 -0
  165. data/examples/rails-demo/test/integration/.keep +0 -0
  166. data/examples/rails-demo/test/mailers/.keep +0 -0
  167. data/examples/rails-demo/test/models/.keep +0 -0
  168. data/examples/rails-demo/test/system/.keep +0 -0
  169. data/examples/rails-demo/test/test_helper.rb +0 -15
  170. data/examples/rails-demo/tmp/.keep +0 -0
  171. data/examples/rails-demo/tmp/pids/.keep +0 -0
  172. data/examples/rails-demo/tmp/storage/.keep +0 -0
  173. data/examples/rails-demo/vendor/.keep +0 -0
  174. data/examples/rails-demo/vendor/javascript/.keep +0 -0
@@ -34,7 +34,7 @@ module Skywalking
34
34
  Dir[File.join(__dir__, 'plugins', '*.rb')].each { |file| require file }
35
35
 
36
36
  installed_plugins = self.class.installed.keys
37
- @enabled_plugins ||= installed_plugins - @config[:disable_plugins].split(',')
37
+ @enabled_plugins ||= installed_plugins - @config[:disable_plugins].split(',').map(&:to_sym)
38
38
  @enabled_plugins.each do |plugin_name|
39
39
  self.class.installed[plugin_name].try_install(plugin_name)
40
40
  end
@@ -83,7 +83,7 @@ module Skywalking
83
83
  endTime: span.end_time,
84
84
  operationName: span.operation,
85
85
  peer: span.peer,
86
- spanType: Tracing.find_mapping(Tracing::Kind, span.kind),
86
+ spanType: span.kind,
87
87
  spanLayer: span.layer,
88
88
  componentId: span.component,
89
89
  refs: span.refs.select { |ref| ref.trace_id }.map do |ref|
@@ -26,7 +26,7 @@ module Skywalking
26
26
  def initialize(config)
27
27
  @config = config
28
28
  @management_service ||= ManagementServiceStub.new(
29
- @config[:collector_backend_service],
29
+ @config[:collector_backend_services],
30
30
  :this_channel_is_insecure
31
31
  )
32
32
  end
@@ -97,7 +97,7 @@ module Skywalking
97
97
  def initialize(config)
98
98
  @config = config
99
99
  @trace_service ||= TraceSegmentReportServiceStub.new(
100
- @config[:collector_backend_service],
100
+ @config[:collector_backend_services],
101
101
  :this_channel_is_insecure
102
102
  )
103
103
  end
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
 
16
16
  require_relative 'grpc'
17
- require_relative 'Scheduler'
17
+ require_relative 'scheduler'
18
18
  require_relative 'buffer_trigger'
19
19
 
20
20
  module Skywalking
@@ -20,7 +20,8 @@ module Skywalking
20
20
  module Tracing
21
21
  class Carrier < CarrierItem
22
22
  attr_reader :trace_id, :correlation_carrier, :service_instance,
23
- :endpoint, :segment_id, :span_id, :peer
23
+ :endpoint, :segment_id, :span_id,
24
+ :peer, :items, :iter_index, :service
24
25
 
25
26
  def initialize(
26
27
  trace_id: '',
@@ -47,7 +48,7 @@ module Skywalking
47
48
  @correlation_carrier.correlation = correlation unless correlation.nil?
48
49
  end
49
50
 
50
- def val
51
+ def value
51
52
  [
52
53
  '1',
53
54
  Base64.strict_encode64(@trace_id),
@@ -56,11 +57,11 @@ module Skywalking
56
57
  Base64.strict_encode64(@service),
57
58
  Base64.strict_encode64(@service_instance),
58
59
  Base64.strict_encode64(@endpoint),
59
- Base64.strict_encode64(@client_address)
60
+ Base64.strict_encode64(@peer)
60
61
  ].join('-')
61
62
  end
62
63
 
63
- def val=(val)
64
+ def value=(val)
64
65
  @val = val
65
66
  return if val.nil? || val.empty?
66
67
 
@@ -73,13 +74,13 @@ module Skywalking
73
74
  @service = Base64.strict_decode64(parts[4])
74
75
  @service_instance = Base64.strict_decode64(parts[5])
75
76
  @endpoint = Base64.strict_decode64(parts[6])
76
- @client_address = Base64.strict_decode64(parts[7])
77
+ @peer = Base64.strict_decode64(parts[7])
77
78
  end
78
79
 
79
80
  def valid?
80
81
  !@trace_id.empty? && !@segment_id.empty? && !@service.empty? &&
81
82
  !@service_instance.empty? && !@endpoint.empty? &&
82
- !@client_address.empty? && @span_id.match?(/^\d+$/)
83
+ !@peer.empty? && @span_id.match?(/^\d+$/)
83
84
  end
84
85
 
85
86
  def suppressed?
@@ -99,13 +100,13 @@ module Skywalking
99
100
  @correlation = {}
100
101
  end
101
102
 
102
- def val
103
+ def value
103
104
  return '' if @correlation.nil? || @correlation.empty?
104
105
 
105
106
  @correlation.map { |k, v| "#{Base64.strict_encode64(k)}:#{Base64.strict_encode64(v)}" }.join(',')
106
107
  end
107
108
 
108
- def val=(val)
109
+ def value=(val)
109
110
  @val = val
110
111
  return if val.nil? || val.empty?
111
112
 
@@ -17,33 +17,28 @@ module Skywalking
17
17
  module Tracing
18
18
  module Component
19
19
  Unknown = 0
20
+ HttpClient = 2
20
21
  Redis = 7
22
+ Memcached = 20
23
+ Elasticsearch = 47
21
24
  General = 12000
22
25
  Sinatra = 12001
23
26
  end
24
27
 
25
28
  module Layer
26
- Unknown = 0
27
- Database = 1
28
- RPCFramework = 2
29
- Http = 3
30
- MQ = 4
31
- Cache = 5
32
- FAAS = 6
29
+ Unknown = "Unknown".freeze
30
+ Database = "Database".freeze
31
+ RPCFramework = "RPCFramework".freeze
32
+ Http = "Http".freeze
33
+ MQ = "MQ".freeze
34
+ Cache = "Cache".freeze
35
+ FAAS = "FAAS".freeze
33
36
  end
34
37
 
35
38
  module Kind
36
- Local = 0
37
- Entry = 1
38
- Exit = 2
39
- end
40
-
41
- def self.find_mapping(category, value)
42
- category.constants.each do |const_name|
43
- return const_name if category.const_get(const_name) == value
44
- end
45
-
46
- 'Unknown'
39
+ Local = "Local".freeze
40
+ Entry = "Entry".freeze
41
+ Exit = "Exit".freeze
47
42
  end
48
43
  end
49
44
  end
@@ -33,7 +33,7 @@ module Skywalking
33
33
  end
34
34
 
35
35
  def cfg
36
- @config ||= ::Skywalking::Agent.config
36
+ @config ||= ::Skywalking::Agent.agent_config
37
37
  end
38
38
 
39
39
  def inject
@@ -19,7 +19,7 @@ module Skywalking
19
19
  module Tracing
20
20
  class NoopSpan < Span
21
21
  def initialize(context: nil)
22
- super(context: context, operation: '', kind: Tracing::Kind::EXIT)
22
+ super(context: context, operation: '', kind: Kind::Exit)
23
23
  end
24
24
 
25
25
  def extract(carrier) end
@@ -32,7 +32,7 @@ module Skywalking
32
32
  end
33
33
 
34
34
  def relate(trace_id)
35
- @related_traces.shift if @related_traces.first.is_a?(Utils::IDGen.new)
35
+ @related_traces.pop if @related_traces[0].is_a?(Utils::IDGen)
36
36
  @related_traces << trace_id
37
37
  end
38
38
  end
@@ -21,7 +21,7 @@ module Skywalking
21
21
  module Tracing
22
22
  class Span
23
23
  attr_accessor :operation, :inherit, :component,
24
- :context, :tags, :peer, :layer
24
+ :context, :tags, :peer, :layer, :error_occurred
25
25
 
26
26
  attr_reader :stack_depth, :kind, :parent_id,
27
27
  :start_time, :end_time, :span_id, :refs
@@ -104,6 +104,7 @@ module Skywalking
104
104
 
105
105
  ref = SegmentRef.new(carrier)
106
106
  @refs << ref unless @refs.include?(ref)
107
+
107
108
  self
108
109
  end
109
110
  end
@@ -36,7 +36,7 @@ module Skywalking
36
36
  end
37
37
 
38
38
  def cfg
39
- @config ||= ::Skywalking::Agent.config
39
+ @config ||= ::Skywalking::Agent.agent_config
40
40
  end
41
41
 
42
42
  def ignore_check(operation, carrier: nil)
@@ -87,7 +87,7 @@ module Skywalking
87
87
  return span if span
88
88
 
89
89
  parent = peek
90
- info 'create new entry span'
90
+ debug 'create new entry span'
91
91
  if parent && parent.kind == Kind::Entry && inherit == parent.component
92
92
  span = parent
93
93
  span.operation = operation
@@ -104,7 +104,7 @@ module Skywalking
104
104
  return span if span
105
105
 
106
106
  parent = peek
107
- info 'create new local span'
107
+ debug 'create new local span'
108
108
  new_span(Span, parent, operation: operation, kind: Kind::Local)
109
109
  end
110
110
 
@@ -113,7 +113,7 @@ module Skywalking
113
113
  return span if span
114
114
 
115
115
  parent = peek
116
- info 'create new exit span'
116
+ debug 'create new exit span'
117
117
 
118
118
  if parent && parent.kind == Kind::Exit && inherit == parent.inherit
119
119
  span = parent
@@ -201,9 +201,9 @@ module Skywalking
201
201
  end
202
202
  end
203
203
 
204
- def new_exit_span(operation:, peer: nil, component: nil, &block)
204
+ def new_exit_span(operation:, peer: nil, component: nil, inherit: nil, &block)
205
205
  context = current_context
206
- span = context.new_exit_span(operation, peer, component: component)
206
+ span = context.new_exit_span(operation, peer, component: component, inherit: inherit)
207
207
  span&.start
208
208
 
209
209
  begin
@@ -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,60 @@ 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 TagDbStatement < Tag
57
+ def initialize(val)
58
+ super
59
+ @key = 'db.statement'
60
+ end
61
+ end
62
+
63
+ class TagCacheType < Tag
64
+ def initialize(val)
65
+ super
66
+ @key = 'cache.type'
67
+ end
68
+ end
69
+
70
+ class TagCacheOp < Tag
71
+ def initialize(val)
72
+ super
73
+ @key = 'cache.op'
74
+ end
75
+ end
76
+
77
+ class TagCacheCmd < Tag
78
+ def initialize(val)
79
+ super
80
+ @key = 'cache.cmd'
81
+ end
82
+ end
83
+
84
+ class TagCacheKey < Tag
85
+ def initialize(val)
86
+ super
87
+ @key = 'cache.key'
88
+ end
89
+ end
90
+
91
+ class TagCacheMiss < Tag
92
+ def initialize(val)
93
+ super
94
+ @key = 'cache.miss'
95
+ end
96
+ end
48
97
  end
49
98
  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.beta2".freeze
18
18
  end
@@ -0,0 +1,58 @@
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.0'
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 'testcontainers-compose', '~> 0.2.0'
57
+ spec.add_development_dependency 'faraday', '~> 2.12'
58
+ 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: 800)
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