skywalking 0.0.0.alpha

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 (184) hide show
  1. checksums.yaml +7 -0
  2. data/.asf.yaml +40 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +236 -0
  5. data/CHANGELOG.md +15 -0
  6. data/CODE_OF_CONDUCT.md +132 -0
  7. data/LICENSE +201 -0
  8. data/NOTICE +5 -0
  9. data/README.md +18 -0
  10. data/Rakefile +23 -0
  11. data/docs/How-to-release.md +179 -0
  12. data/examples/rails-demo/.dockerignore +47 -0
  13. data/examples/rails-demo/.gitattributes +9 -0
  14. data/examples/rails-demo/.gitignore +34 -0
  15. data/examples/rails-demo/.kamal/hooks/docker-setup.sample +3 -0
  16. data/examples/rails-demo/.kamal/hooks/post-deploy.sample +14 -0
  17. data/examples/rails-demo/.kamal/hooks/post-proxy-reboot.sample +3 -0
  18. data/examples/rails-demo/.kamal/hooks/pre-build.sample +51 -0
  19. data/examples/rails-demo/.kamal/hooks/pre-connect.sample +47 -0
  20. data/examples/rails-demo/.kamal/hooks/pre-deploy.sample +109 -0
  21. data/examples/rails-demo/.kamal/hooks/pre-proxy-reboot.sample +3 -0
  22. data/examples/rails-demo/.kamal/secrets +17 -0
  23. data/examples/rails-demo/.rubocop.yml +8 -0
  24. data/examples/rails-demo/.ruby-version +1 -0
  25. data/examples/rails-demo/Dockerfile +72 -0
  26. data/examples/rails-demo/Gemfile +64 -0
  27. data/examples/rails-demo/README.md +24 -0
  28. data/examples/rails-demo/Rakefile +6 -0
  29. data/examples/rails-demo/app/assets/images/.keep +0 -0
  30. data/examples/rails-demo/app/assets/stylesheets/application.css +10 -0
  31. data/examples/rails-demo/app/controllers/application_controller.rb +4 -0
  32. data/examples/rails-demo/app/controllers/concerns/.keep +0 -0
  33. data/examples/rails-demo/app/helpers/application_helper.rb +2 -0
  34. data/examples/rails-demo/app/javascript/application.js +3 -0
  35. data/examples/rails-demo/app/javascript/controllers/application.js +9 -0
  36. data/examples/rails-demo/app/javascript/controllers/hello_controller.js +7 -0
  37. data/examples/rails-demo/app/javascript/controllers/index.js +4 -0
  38. data/examples/rails-demo/app/jobs/application_job.rb +7 -0
  39. data/examples/rails-demo/app/mailers/application_mailer.rb +4 -0
  40. data/examples/rails-demo/app/models/application_record.rb +3 -0
  41. data/examples/rails-demo/app/models/concerns/.keep +0 -0
  42. data/examples/rails-demo/app/views/layouts/application.html.erb +28 -0
  43. data/examples/rails-demo/app/views/layouts/mailer.html.erb +13 -0
  44. data/examples/rails-demo/app/views/layouts/mailer.text.erb +1 -0
  45. data/examples/rails-demo/app/views/pwa/manifest.json.erb +22 -0
  46. data/examples/rails-demo/app/views/pwa/service-worker.js +26 -0
  47. data/examples/rails-demo/bin/brakeman +7 -0
  48. data/examples/rails-demo/bin/bundle +109 -0
  49. data/examples/rails-demo/bin/dev +2 -0
  50. data/examples/rails-demo/bin/docker-entrypoint +14 -0
  51. data/examples/rails-demo/bin/importmap +4 -0
  52. data/examples/rails-demo/bin/jobs +6 -0
  53. data/examples/rails-demo/bin/kamal +27 -0
  54. data/examples/rails-demo/bin/rails +4 -0
  55. data/examples/rails-demo/bin/rake +4 -0
  56. data/examples/rails-demo/bin/rubocop +8 -0
  57. data/examples/rails-demo/bin/setup +34 -0
  58. data/examples/rails-demo/bin/thrust +5 -0
  59. data/examples/rails-demo/config/application.rb +27 -0
  60. data/examples/rails-demo/config/boot.rb +4 -0
  61. data/examples/rails-demo/config/cable.yml +17 -0
  62. data/examples/rails-demo/config/cache.yml +16 -0
  63. data/examples/rails-demo/config/credentials.yml.enc +1 -0
  64. data/examples/rails-demo/config/database.yml +41 -0
  65. data/examples/rails-demo/config/deploy.yml +116 -0
  66. data/examples/rails-demo/config/environment.rb +5 -0
  67. data/examples/rails-demo/config/environments/development.rb +72 -0
  68. data/examples/rails-demo/config/environments/production.rb +90 -0
  69. data/examples/rails-demo/config/environments/test.rb +53 -0
  70. data/examples/rails-demo/config/importmap.rb +7 -0
  71. data/examples/rails-demo/config/initializers/assets.rb +7 -0
  72. data/examples/rails-demo/config/initializers/content_security_policy.rb +25 -0
  73. data/examples/rails-demo/config/initializers/filter_parameter_logging.rb +8 -0
  74. data/examples/rails-demo/config/initializers/inflections.rb +16 -0
  75. data/examples/rails-demo/config/initializers/skywalking_ruby.rb +18 -0
  76. data/examples/rails-demo/config/locales/en.yml +31 -0
  77. data/examples/rails-demo/config/puma.rb +41 -0
  78. data/examples/rails-demo/config/queue.yml +18 -0
  79. data/examples/rails-demo/config/recurring.yml +10 -0
  80. data/examples/rails-demo/config/routes.rb +14 -0
  81. data/examples/rails-demo/config/storage.yml +34 -0
  82. data/examples/rails-demo/config.ru +6 -0
  83. data/examples/rails-demo/db/cable_schema.rb +11 -0
  84. data/examples/rails-demo/db/cache_schema.rb +14 -0
  85. data/examples/rails-demo/db/queue_schema.rb +129 -0
  86. data/examples/rails-demo/db/seeds.rb +9 -0
  87. data/examples/rails-demo/lib/tasks/.keep +0 -0
  88. data/examples/rails-demo/log/.keep +0 -0
  89. data/examples/rails-demo/public/400.html +114 -0
  90. data/examples/rails-demo/public/404.html +114 -0
  91. data/examples/rails-demo/public/406-unsupported-browser.html +114 -0
  92. data/examples/rails-demo/public/422.html +114 -0
  93. data/examples/rails-demo/public/500.html +114 -0
  94. data/examples/rails-demo/public/icon.png +0 -0
  95. data/examples/rails-demo/public/icon.svg +3 -0
  96. data/examples/rails-demo/public/robots.txt +1 -0
  97. data/examples/rails-demo/script/.keep +0 -0
  98. data/examples/rails-demo/storage/.keep +0 -0
  99. data/examples/rails-demo/test/application_system_test_case.rb +5 -0
  100. data/examples/rails-demo/test/controllers/.keep +0 -0
  101. data/examples/rails-demo/test/fixtures/files/.keep +0 -0
  102. data/examples/rails-demo/test/helpers/.keep +0 -0
  103. data/examples/rails-demo/test/integration/.keep +0 -0
  104. data/examples/rails-demo/test/mailers/.keep +0 -0
  105. data/examples/rails-demo/test/models/.keep +0 -0
  106. data/examples/rails-demo/test/system/.keep +0 -0
  107. data/examples/rails-demo/test/test_helper.rb +15 -0
  108. data/examples/rails-demo/tmp/.keep +0 -0
  109. data/examples/rails-demo/tmp/pids/.keep +0 -0
  110. data/examples/rails-demo/tmp/storage/.keep +0 -0
  111. data/examples/rails-demo/vendor/.keep +0 -0
  112. data/examples/rails-demo/vendor/javascript/.keep +0 -0
  113. data/examples/sinatra-demo/sinatra-demo.rb +32 -0
  114. data/lib/skywalking/agent.rb +98 -0
  115. data/lib/skywalking/configuration.rb +255 -0
  116. data/lib/skywalking/environment.rb +50 -0
  117. data/lib/skywalking/log/logger.rb +53 -0
  118. data/lib/skywalking/plugins/redis5.rb +70 -0
  119. data/lib/skywalking/plugins/sinatra.rb +55 -0
  120. data/lib/skywalking/plugins_manager.rb +84 -0
  121. data/lib/skywalking/proto/asyncprofiler/AsyncProfiler_pb.rb +23 -0
  122. data/lib/skywalking/proto/asyncprofiler/AsyncProfiler_services_pb.rb +45 -0
  123. data/lib/skywalking/proto/browser/BrowserPerfCompat_pb.rb +15 -0
  124. data/lib/skywalking/proto/browser/BrowserPerfCompat_services_pb.rb +42 -0
  125. data/lib/skywalking/proto/browser/BrowserPerf_pb.rb +21 -0
  126. data/lib/skywalking/proto/browser/BrowserPerf_services_pb.rb +46 -0
  127. data/lib/skywalking/proto/common/Command_pb.rb +20 -0
  128. data/lib/skywalking/proto/common/Common_pb.rb +21 -0
  129. data/lib/skywalking/proto/ebpf/accesslog_pb.rb +58 -0
  130. data/lib/skywalking/proto/ebpf/accesslog_services_pb.rb +42 -0
  131. data/lib/skywalking/proto/event/Event_pb.rb +21 -0
  132. data/lib/skywalking/proto/event/Event_services_pb.rb +45 -0
  133. data/lib/skywalking/proto/language-agent/CLRMetricCompat_pb.rb +15 -0
  134. data/lib/skywalking/proto/language-agent/CLRMetricCompat_services_pb.rb +38 -0
  135. data/lib/skywalking/proto/language-agent/CLRMetric_pb.rb +23 -0
  136. data/lib/skywalking/proto/language-agent/CLRMetric_services_pb.rb +42 -0
  137. data/lib/skywalking/proto/language-agent/ConfigurationDiscoveryService_pb.rb +19 -0
  138. data/lib/skywalking/proto/language-agent/ConfigurationDiscoveryService_services_pb.rb +51 -0
  139. data/lib/skywalking/proto/language-agent/JVMMetricCompat_pb.rb +15 -0
  140. data/lib/skywalking/proto/language-agent/JVMMetricCompat_services_pb.rb +39 -0
  141. data/lib/skywalking/proto/language-agent/JVMMetric_pb.rb +28 -0
  142. data/lib/skywalking/proto/language-agent/JVMMetric_services_pb.rb +43 -0
  143. data/lib/skywalking/proto/language-agent/MeterCompat_pb.rb +15 -0
  144. data/lib/skywalking/proto/language-agent/MeterCompat_services_pb.rb +39 -0
  145. data/lib/skywalking/proto/language-agent/Meter_pb.rb +24 -0
  146. data/lib/skywalking/proto/language-agent/Meter_services_pb.rb +48 -0
  147. data/lib/skywalking/proto/language-agent/TracingCompat_pb.rb +15 -0
  148. data/lib/skywalking/proto/language-agent/TracingCompat_services_pb.rb +48 -0
  149. data/lib/skywalking/proto/language-agent/Tracing_pb.rb +31 -0
  150. data/lib/skywalking/proto/language-agent/Tracing_services_pb.rb +71 -0
  151. data/lib/skywalking/proto/logging/Logging_pb.rb +26 -0
  152. data/lib/skywalking/proto/logging/Logging_services_pb.rb +46 -0
  153. data/lib/skywalking/proto/management/ManagementCompat_pb.rb +15 -0
  154. data/lib/skywalking/proto/management/ManagementCompat_services_pb.rb +44 -0
  155. data/lib/skywalking/proto/management/Management_pb.rb +21 -0
  156. data/lib/skywalking/proto/management/Management_services_pb.rb +48 -0
  157. data/lib/skywalking/proto/profile/ProfileCompat_pb.rb +15 -0
  158. data/lib/skywalking/proto/profile/ProfileCompat_services_pb.rb +43 -0
  159. data/lib/skywalking/proto/profile/Profile_pb.rb +22 -0
  160. data/lib/skywalking/proto/profile/Profile_services_pb.rb +47 -0
  161. data/lib/skywalking/proto/service-mesh-probe/service-mesh_pb.rb +25 -0
  162. data/lib/skywalking/proto/service-mesh-probe/service-mesh_services_pb.rb +43 -0
  163. data/lib/skywalking/reporter/buffer_trigger.rb +108 -0
  164. data/lib/skywalking/reporter/client/grpc_client.rb +114 -0
  165. data/lib/skywalking/reporter/client/proto.rb +29 -0
  166. data/lib/skywalking/reporter/grpc.rb +46 -0
  167. data/lib/skywalking/reporter/protocol.rb +28 -0
  168. data/lib/skywalking/reporter/report.rb +82 -0
  169. data/lib/skywalking/reporter/scheduler.rb +158 -0
  170. data/lib/skywalking/tracing/carrier.rb +121 -0
  171. data/lib/skywalking/tracing/carrier_item.rb +27 -0
  172. data/lib/skywalking/tracing/constants.rb +49 -0
  173. data/lib/skywalking/tracing/entry_span.rb +48 -0
  174. data/lib/skywalking/tracing/exit_span.rb +53 -0
  175. data/lib/skywalking/tracing/ignored_context.rb +34 -0
  176. data/lib/skywalking/tracing/noop_span.rb +32 -0
  177. data/lib/skywalking/tracing/segment.rb +57 -0
  178. data/lib/skywalking/tracing/span.rb +111 -0
  179. data/lib/skywalking/tracing/span_context.rb +242 -0
  180. data/lib/skywalking/tracing/tag.rb +49 -0
  181. data/lib/skywalking/utils/id_gen.rb +30 -0
  182. data/lib/skywalking/version.rb +18 -0
  183. data/lib/skywalking.rb +36 -0
  184. metadata +340 -0
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: logging/Logging.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require_relative '../common/Common_pb'
8
+ require_relative '../common/Command_pb'
9
+
10
+
11
+ descriptor_data = "\n\x15logging/Logging.proto\x12\rskywalking.v3\x1a\x13\x63ommon/Common.proto\x1a\x14\x63ommon/Command.proto\"\xea\x01\n\x07LogData\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\x12\x0f\n\x07service\x18\x02 \x01(\t\x12\x17\n\x0fserviceInstance\x18\x03 \x01(\t\x12\x10\n\x08\x65ndpoint\x18\x04 \x01(\t\x12(\n\x04\x62ody\x18\x05 \x01(\x0b\x32\x1a.skywalking.v3.LogDataBody\x12\x31\n\x0ctraceContext\x18\x06 \x01(\x0b\x32\x1b.skywalking.v3.TraceContext\x12$\n\x04tags\x18\x07 \x01(\x0b\x32\x16.skywalking.v3.LogTags\x12\r\n\x05layer\x18\x08 \x01(\t\"\x9e\x01\n\x0bLogDataBody\x12\x0c\n\x04type\x18\x01 \x01(\t\x12&\n\x04text\x18\x02 \x01(\x0b\x32\x16.skywalking.v3.TextLogH\x00\x12&\n\x04json\x18\x03 \x01(\x0b\x32\x16.skywalking.v3.JSONLogH\x00\x12&\n\x04yaml\x18\x04 \x01(\x0b\x32\x16.skywalking.v3.YAMLLogH\x00\x42\t\n\x07\x63ontent\"\x17\n\x07TextLog\x12\x0c\n\x04text\x18\x01 \x01(\t\"\x17\n\x07JSONLog\x12\x0c\n\x04json\x18\x01 \x01(\t\"\x17\n\x07YAMLLog\x12\x0c\n\x04yaml\x18\x01 \x01(\t\"G\n\x0cTraceContext\x12\x0f\n\x07traceId\x18\x01 \x01(\t\x12\x16\n\x0etraceSegmentId\x18\x02 \x01(\t\x12\x0e\n\x06spanId\x18\x03 \x01(\x05\":\n\x07LogTags\x12/\n\x04\x64\x61ta\x18\x01 \x03(\x0b\x32!.skywalking.v3.KeyStringValuePair2R\n\x10LogReportService\x12>\n\x07\x63ollect\x12\x16.skywalking.v3.LogData\x1a\x17.skywalking.v3.Commands\"\x00(\x01\x42\x85\x01\n,org.apache.skywalking.apm.network.logging.v3P\x01Z3skywalking.apache.org/repo/goapi/collect/logging/v3\xaa\x02\x1dSkyWalking.NetworkProtocol.V3b\x06proto3"
12
+
13
+ pool = Google::Protobuf::DescriptorPool.generated_pool
14
+ pool.add_serialized_file(descriptor_data)
15
+
16
+ module Skywalking
17
+ module V3
18
+ LogData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.LogData").msgclass
19
+ LogDataBody = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.LogDataBody").msgclass
20
+ TextLog = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.TextLog").msgclass
21
+ JSONLog = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.JSONLog").msgclass
22
+ YAMLLog = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.YAMLLog").msgclass
23
+ TraceContext = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.TraceContext").msgclass
24
+ LogTags = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.LogTags").msgclass
25
+ end
26
+ end
@@ -0,0 +1,46 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: logging/Logging.proto for package 'skywalking.v3'
3
+ # Original file comments:
4
+ #
5
+ # Licensed to the Apache Software Foundation (ASF) under one or more
6
+ # contributor license agreements. See the NOTICE file distributed with
7
+ # this work for additional information regarding copyright ownership.
8
+ # The ASF licenses this file to You under the Apache License, Version 2.0
9
+ # (the "License"); you may not use this file except in compliance with
10
+ # the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ #
21
+
22
+ require 'grpc'
23
+ require_relative 'Logging_pb'
24
+
25
+ module Skywalking
26
+ module V3
27
+ module LogReportService
28
+ # Report collected logs into the OAP backend
29
+ class Service
30
+
31
+ include ::GRPC::GenericService
32
+
33
+ self.marshal_class_method = :encode
34
+ self.unmarshal_class_method = :decode
35
+ self.service_name = 'skywalking.v3.LogReportService'
36
+
37
+ # Recommend to report log data in a stream mode.
38
+ # The service/instance/endpoint of the log could share the previous value if they are not set.
39
+ # Reporting the logs of same service in the batch mode could reduce the network cost.
40
+ rpc :collect, stream(::Skywalking::V3::LogData), ::Skywalking::V3::Commands
41
+ end
42
+
43
+ Stub = Service.rpc_stub_class
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: management/ManagementCompat.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require_relative '../common/Command_pb'
8
+ require_relative 'Management_pb'
9
+
10
+
11
+ descriptor_data = "\n!management/ManagementCompat.proto\x1a\x14\x63ommon/Command.proto\x1a\x1bmanagement/Management.proto2\xb5\x01\n\x11ManagementService\x12X\n\x18reportInstanceProperties\x12!.skywalking.v3.InstanceProperties\x1a\x17.skywalking.v3.Commands\"\x00\x12\x46\n\tkeepAlive\x12\x1e.skywalking.v3.InstancePingPkg\x1a\x17.skywalking.v3.Commands\"\x00\x42\xa3\x01\n6org.apache.skywalking.apm.network.management.v3.compatP\x01Z=skywalking.apache.org/repo/goapi/collect/management/v3/compat\xb8\x01\x01\xaa\x02$SkyWalking.NetworkProtocol.V3.Compatb\x06proto3"
12
+
13
+ pool = Google::Protobuf::DescriptorPool.generated_pool
14
+ pool.add_serialized_file(descriptor_data)
15
+
@@ -0,0 +1,44 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: management/ManagementCompat.proto for package ''
3
+ # Original file comments:
4
+ #
5
+ # Licensed to the Apache Software Foundation (ASF) under one or more
6
+ # contributor license agreements. See the NOTICE file distributed with
7
+ # this work for additional information regarding copyright ownership.
8
+ # The ASF licenses this file to You under the Apache License, Version 2.0
9
+ # (the "License"); you may not use this file except in compliance with
10
+ # the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ #
21
+
22
+ require 'grpc'
23
+ require_relative 'ManagementCompat_pb'
24
+
25
+ module ManagementService
26
+ # Define the service reporting the extra information of the instance.
27
+ class Service
28
+
29
+ include ::GRPC::GenericService
30
+
31
+ self.marshal_class_method = :encode
32
+ self.unmarshal_class_method = :decode
33
+ self.service_name = 'ManagementService'
34
+
35
+ # Report custom properties of a service instance.
36
+ rpc :reportInstanceProperties, ::Skywalking::V3::InstanceProperties, ::Skywalking::V3::Commands
37
+ # Keep the instance alive in the backend analysis.
38
+ # Only recommend to do separate keepAlive report when no trace and metrics needs to be reported.
39
+ # Otherwise, it is duplicated.
40
+ rpc :keepAlive, ::Skywalking::V3::InstancePingPkg, ::Skywalking::V3::Commands
41
+ end
42
+
43
+ Stub = Service.rpc_stub_class
44
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: management/Management.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require_relative '../common/Common_pb'
8
+ require_relative '../common/Command_pb'
9
+
10
+
11
+ descriptor_data = "\n\x1bmanagement/Management.proto\x12\rskywalking.v3\x1a\x13\x63ommon/Common.proto\x1a\x14\x63ommon/Command.proto\"\x84\x01\n\x12InstanceProperties\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x17\n\x0fserviceInstance\x18\x02 \x01(\t\x12\x35\n\nproperties\x18\x03 \x03(\x0b\x32!.skywalking.v3.KeyStringValuePair\x12\r\n\x05layer\x18\x04 \x01(\t\"J\n\x0fInstancePingPkg\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x17\n\x0fserviceInstance\x18\x02 \x01(\t\x12\r\n\x05layer\x18\x03 \x01(\t2\xb5\x01\n\x11ManagementService\x12X\n\x18reportInstanceProperties\x12!.skywalking.v3.InstanceProperties\x1a\x17.skywalking.v3.Commands\"\x00\x12\x46\n\tkeepAlive\x12\x1e.skywalking.v3.InstancePingPkg\x1a\x17.skywalking.v3.Commands\"\x00\x42\x8b\x01\n/org.apache.skywalking.apm.network.management.v3P\x01Z6skywalking.apache.org/repo/goapi/collect/management/v3\xaa\x02\x1dSkyWalking.NetworkProtocol.V3b\x06proto3"
12
+
13
+ pool = Google::Protobuf::DescriptorPool.generated_pool
14
+ pool.add_serialized_file(descriptor_data)
15
+
16
+ module Skywalking
17
+ module V3
18
+ InstanceProperties = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.InstanceProperties").msgclass
19
+ InstancePingPkg = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.InstancePingPkg").msgclass
20
+ end
21
+ end
@@ -0,0 +1,48 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: management/Management.proto for package 'skywalking.v3'
3
+ # Original file comments:
4
+ #
5
+ # Licensed to the Apache Software Foundation (ASF) under one or more
6
+ # contributor license agreements. See the NOTICE file distributed with
7
+ # this work for additional information regarding copyright ownership.
8
+ # The ASF licenses this file to You under the Apache License, Version 2.0
9
+ # (the "License"); you may not use this file except in compliance with
10
+ # the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ #
21
+
22
+ require 'grpc'
23
+ require_relative '../management/Management_pb'
24
+
25
+ module Skywalking
26
+ module V3
27
+ module ManagementService
28
+ # Define the service reporting the extra information of the instance.
29
+ class Service
30
+
31
+ include ::GRPC::GenericService
32
+
33
+ self.marshal_class_method = :encode
34
+ self.unmarshal_class_method = :decode
35
+ self.service_name = 'skywalking.v3.ManagementService'
36
+
37
+ # Report custom properties of a service instance.
38
+ rpc :reportInstanceProperties, ::Skywalking::V3::InstanceProperties, ::Skywalking::V3::Commands
39
+ # Keep the instance alive in the backend analysis.
40
+ # Only recommend to do separate keepAlive report when no trace and metrics needs to be reported.
41
+ # Otherwise, it is duplicated.
42
+ rpc :keepAlive, ::Skywalking::V3::InstancePingPkg, ::Skywalking::V3::Commands
43
+ end
44
+
45
+ Stub = Service.rpc_stub_class
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: profile/ProfileCompat.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require_relative '../common/Command_pb'
8
+ require_relative 'Profile_pb'
9
+
10
+
11
+ descriptor_data = "\n\x1bprofile/ProfileCompat.proto\x1a\x14\x63ommon/Command.proto\x1a\x15profile/Profile.proto2\x90\x02\n\x0bProfileTask\x12[\n\x16getProfileTaskCommands\x12&.skywalking.v3.ProfileTaskCommandQuery\x1a\x17.skywalking.v3.Commands\"\x00\x12M\n\x0f\x63ollectSnapshot\x12\x1d.skywalking.v3.ThreadSnapshot\x1a\x17.skywalking.v3.Commands\"\x00(\x01\x12U\n\x10reportTaskFinish\x12&.skywalking.v3.ProfileTaskFinishReport\x1a\x17.skywalking.v3.Commands\"\x00\x42\xaf\x01\n<org.apache.skywalking.apm.network.language.profile.v3.compatP\x01ZCskywalking.apache.org/repo/goapi/collect/language/profile/v3/compat\xb8\x01\x01\xaa\x02$SkyWalking.NetworkProtocol.V3.Compatb\x06proto3"
12
+
13
+ pool = Google::Protobuf::DescriptorPool.generated_pool
14
+ pool.add_serialized_file(descriptor_data)
15
+
@@ -0,0 +1,43 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: profile/ProfileCompat.proto for package ''
3
+ # Original file comments:
4
+ #
5
+ # Licensed to the Apache Software Foundation (ASF) under one or more
6
+ # contributor license agreements. See the NOTICE file distributed with
7
+ # this work for additional information regarding copyright ownership.
8
+ # The ASF licenses this file to You under the Apache License, Version 2.0
9
+ # (the "License"); you may not use this file except in compliance with
10
+ # the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ #
21
+
22
+ require 'grpc'
23
+ require_relative 'ProfileCompat_pb'
24
+
25
+ module ProfileTask
26
+ class Service
27
+
28
+ include ::GRPC::GenericService
29
+
30
+ self.marshal_class_method = :encode
31
+ self.unmarshal_class_method = :decode
32
+ self.service_name = 'ProfileTask'
33
+
34
+ # query all sniffer need to execute profile task commands
35
+ rpc :getProfileTaskCommands, ::Skywalking::V3::ProfileTaskCommandQuery, ::Skywalking::V3::Commands
36
+ # collect dumped thread snapshot
37
+ rpc :collectSnapshot, stream(::Skywalking::V3::ThreadSnapshot), ::Skywalking::V3::Commands
38
+ # report profiling task finished
39
+ rpc :reportTaskFinish, ::Skywalking::V3::ProfileTaskFinishReport, ::Skywalking::V3::Commands
40
+ end
41
+
42
+ Stub = Service.rpc_stub_class
43
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: profile/Profile.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require_relative '../common/Command_pb'
8
+
9
+
10
+ descriptor_data = "\n\x15profile/Profile.proto\x12\rskywalking.v3\x1a\x14\x63ommon/Command.proto\"\\\n\x17ProfileTaskCommandQuery\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x17\n\x0fserviceInstance\x18\x02 \x01(\t\x12\x17\n\x0flastCommandTime\x18\x03 \x01(\x03\"\x83\x01\n\x0eThreadSnapshot\x12\x0e\n\x06taskId\x18\x01 \x01(\t\x12\x16\n\x0etraceSegmentId\x18\x02 \x01(\t\x12\x0c\n\x04time\x18\x03 \x01(\x03\x12\x10\n\x08sequence\x18\x04 \x01(\x05\x12)\n\x05stack\x18\x05 \x01(\x0b\x32\x1a.skywalking.v3.ThreadStack\"%\n\x0bThreadStack\x12\x16\n\x0e\x63odeSignatures\x18\x01 \x03(\t\"S\n\x17ProfileTaskFinishReport\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x17\n\x0fserviceInstance\x18\x02 \x01(\t\x12\x0e\n\x06taskId\x18\x03 \x01(\t2\x90\x02\n\x0bProfileTask\x12[\n\x16getProfileTaskCommands\x12&.skywalking.v3.ProfileTaskCommandQuery\x1a\x17.skywalking.v3.Commands\"\x00\x12M\n\x0f\x63ollectSnapshot\x12\x1d.skywalking.v3.ThreadSnapshot\x1a\x17.skywalking.v3.Commands\"\x00(\x01\x12U\n\x10reportTaskFinish\x12&.skywalking.v3.ProfileTaskFinishReport\x1a\x17.skywalking.v3.Commands\"\x00\x42\x97\x01\n5org.apache.skywalking.apm.network.language.profile.v3P\x01Z<skywalking.apache.org/repo/goapi/collect/language/profile/v3\xaa\x02\x1dSkyWalking.NetworkProtocol.V3b\x06proto3"
11
+
12
+ pool = Google::Protobuf::DescriptorPool.generated_pool
13
+ pool.add_serialized_file(descriptor_data)
14
+
15
+ module Skywalking
16
+ module V3
17
+ ProfileTaskCommandQuery = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.ProfileTaskCommandQuery").msgclass
18
+ ThreadSnapshot = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.ThreadSnapshot").msgclass
19
+ ThreadStack = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.ThreadStack").msgclass
20
+ ProfileTaskFinishReport = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.ProfileTaskFinishReport").msgclass
21
+ end
22
+ end
@@ -0,0 +1,47 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: profile/Profile.proto for package 'skywalking.v3'
3
+ # Original file comments:
4
+ #
5
+ # Licensed to the Apache Software Foundation (ASF) under one or more
6
+ # contributor license agreements. See the NOTICE file distributed with
7
+ # this work for additional information regarding copyright ownership.
8
+ # The ASF licenses this file to You under the Apache License, Version 2.0
9
+ # (the "License"); you may not use this file except in compliance with
10
+ # the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ #
21
+
22
+ require 'grpc'
23
+ require_relative 'Profile_pb'
24
+
25
+ module Skywalking
26
+ module V3
27
+ module ProfileTask
28
+ class Service
29
+
30
+ include ::GRPC::GenericService
31
+
32
+ self.marshal_class_method = :encode
33
+ self.unmarshal_class_method = :decode
34
+ self.service_name = 'skywalking.v3.ProfileTask'
35
+
36
+ # query all sniffer need to execute profile task commands
37
+ rpc :getProfileTaskCommands, ::Skywalking::V3::ProfileTaskCommandQuery, ::Skywalking::V3::Commands
38
+ # collect dumped thread snapshot
39
+ rpc :collectSnapshot, stream(::Skywalking::V3::ThreadSnapshot), ::Skywalking::V3::Commands
40
+ # report profiling task finished
41
+ rpc :reportTaskFinish, ::Skywalking::V3::ProfileTaskFinishReport, ::Skywalking::V3::Commands
42
+ end
43
+
44
+ Stub = Service.rpc_stub_class
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: service-mesh-probe/service-mesh.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require_relative '../common/Common_pb'
8
+
9
+
10
+ descriptor_data = "\n%service-mesh-probe/service-mesh.proto\x12\rskywalking.v3\x1a\x13\x63ommon/Common.proto\"\x99\x01\n\x12ServiceMeshMetrics\x12<\n\x0bhttpMetrics\x18\x01 \x01(\x0b\x32%.skywalking.v3.HTTPServiceMeshMetricsH\x00\x12:\n\ntcpMetrics\x18\x02 \x01(\x0b\x32$.skywalking.v3.TCPServiceMeshMetricsH\x00\x42\t\n\x07metrics\"\xcf\x04\n\x15HTTPServiceMeshMetric\x12\x11\n\tstartTime\x18\x01 \x01(\x03\x12\x0f\n\x07\x65ndTime\x18\x02 \x01(\x03\x12\x19\n\x11sourceServiceName\x18\x03 \x01(\t\x12\x1d\n\x15sourceServiceInstance\x18\x04 \x01(\t\x12\x17\n\x0f\x64\x65stServiceName\x18\x05 \x01(\t\x12\x1b\n\x13\x64\x65stServiceInstance\x18\x06 \x01(\t\x12\x10\n\x08\x65ndpoint\x18\x07 \x01(\t\x12\x0f\n\x07latency\x18\x08 \x01(\x05\x12\x14\n\x0cresponseCode\x18\t \x01(\x05\x12\x0e\n\x06status\x18\n \x01(\x08\x12)\n\x08protocol\x18\x0b \x01(\x0e\x32\x17.skywalking.v3.Protocol\x12/\n\x0b\x64\x65tectPoint\x18\x0c \x01(\x0e\x32\x1a.skywalking.v3.DetectPoint\x12\x0f\n\x07tlsMode\x18\r \x01(\t\x12\x19\n\x11internalErrorCode\x18\x0e \x01(\t\x12#\n\x1binternalRequestLatencyNanos\x18\x0f \x01(\x03\x12$\n\x1cinternalResponseLatencyNanos\x18\x10 \x01(\x03\x12\x43\n\x18sourceInstanceProperties\x18\x11 \x03(\x0b\x32!.skywalking.v3.KeyStringValuePair\x12\x41\n\x16\x64\x65stInstanceProperties\x18\x12 \x03(\x0b\x32!.skywalking.v3.KeyStringValuePair\"O\n\x16HTTPServiceMeshMetrics\x12\x35\n\x07metrics\x18\x01 \x03(\x0b\x32$.skywalking.v3.HTTPServiceMeshMetric\"\x84\x04\n\x14TCPServiceMeshMetric\x12\x11\n\tstartTime\x18\x01 \x01(\x03\x12\x0f\n\x07\x65ndTime\x18\x02 \x01(\x03\x12\x19\n\x11sourceServiceName\x18\x03 \x01(\t\x12\x1d\n\x15sourceServiceInstance\x18\x04 \x01(\t\x12\x17\n\x0f\x64\x65stServiceName\x18\x05 \x01(\t\x12\x1b\n\x13\x64\x65stServiceInstance\x18\x06 \x01(\t\x12/\n\x0b\x64\x65tectPoint\x18\x07 \x01(\x0e\x32\x1a.skywalking.v3.DetectPoint\x12\x0f\n\x07tlsMode\x18\x08 \x01(\t\x12\x19\n\x11internalErrorCode\x18\t \x01(\t\x12#\n\x1binternalRequestLatencyNanos\x18\n \x01(\x03\x12$\n\x1cinternalResponseLatencyNanos\x18\x0b \x01(\x03\x12\x43\n\x18sourceInstanceProperties\x18\x0c \x03(\x0b\x32!.skywalking.v3.KeyStringValuePair\x12\x41\n\x16\x64\x65stInstanceProperties\x18\r \x03(\x0b\x32!.skywalking.v3.KeyStringValuePair\x12\x15\n\rreceivedBytes\x18\x0e \x01(\x03\x12\x11\n\tsentBytes\x18\x0f \x01(\x03\"M\n\x15TCPServiceMeshMetrics\x12\x34\n\x07metrics\x18\x01 \x03(\x0b\x32#.skywalking.v3.TCPServiceMeshMetric\"\x15\n\x13MeshProbeDownstream*\x1e\n\x08Protocol\x12\x08\n\x04HTTP\x10\x00\x12\x08\n\x04gRPC\x10\x01\x32p\n\x18ServiceMeshMetricService\x12T\n\x07\x63ollect\x12!.skywalking.v3.ServiceMeshMetrics\x1a\".skywalking.v3.MeshProbeDownstream\"\x00(\x01\x42\x8d\x01\n0org.apache.skywalking.apm.network.servicemesh.v3P\x01Z7skywalking.apache.org/repo/goapi/collect/servicemesh/v3\xaa\x02\x1dSkyWalking.NetworkProtocol.V3b\x06proto3"
11
+
12
+ pool = Google::Protobuf::DescriptorPool.generated_pool
13
+ pool.add_serialized_file(descriptor_data)
14
+
15
+ module Skywalking
16
+ module V3
17
+ ServiceMeshMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.ServiceMeshMetrics").msgclass
18
+ HTTPServiceMeshMetric = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.HTTPServiceMeshMetric").msgclass
19
+ HTTPServiceMeshMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.HTTPServiceMeshMetrics").msgclass
20
+ TCPServiceMeshMetric = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.TCPServiceMeshMetric").msgclass
21
+ TCPServiceMeshMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.TCPServiceMeshMetrics").msgclass
22
+ MeshProbeDownstream = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.MeshProbeDownstream").msgclass
23
+ Protocol = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("skywalking.v3.Protocol").enummodule
24
+ end
25
+ end
@@ -0,0 +1,43 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: service-mesh-probe/service-mesh.proto for package 'skywalking.v3'
3
+ # Original file comments:
4
+ #
5
+ # Licensed to the Apache Software Foundation (ASF) under one or more
6
+ # contributor license agreements. See the NOTICE file distributed with
7
+ # this work for additional information regarding copyright ownership.
8
+ # The ASF licenses this file to You under the Apache License, Version 2.0
9
+ # (the "License"); you may not use this file except in compliance with
10
+ # the License. You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ #
21
+
22
+ require 'grpc'
23
+ require_relative 'service-mesh_pb'
24
+
25
+ module Skywalking
26
+ module V3
27
+ module ServiceMeshMetricService
28
+ # Define metrics report service. The metrics format is typically representing the data model collected in the service mesh case.
29
+ class Service
30
+
31
+ include ::GRPC::GenericService
32
+
33
+ self.marshal_class_method = :encode
34
+ self.unmarshal_class_method = :decode
35
+ self.service_name = 'skywalking.v3.ServiceMeshMetricService'
36
+
37
+ rpc :collect, stream(::Skywalking::V3::ServiceMeshMetrics), ::Skywalking::V3::MeshProbeDownstream
38
+ end
39
+
40
+ Stub = Service.rpc_stub_class
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,108 @@
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 'client/proto'
17
+
18
+ module Skywalking
19
+ module Reporter
20
+ class BufferTrigger
21
+ include Enumerable
22
+
23
+ extend Forwardable
24
+ def_delegators :@buffer, :push
25
+
26
+ def initialize(config)
27
+ @config = config
28
+ @max_size = @config[:max_queue_size]
29
+ @buffer = Queue.new
30
+ @mutex = Mutex.new
31
+ @closed = false
32
+ end
33
+
34
+ def empty?
35
+ @buffer.empty?
36
+ end
37
+
38
+ def <<(segment)
39
+ @mutex.synchronize do
40
+ clear_queue if @buffer.size >= @max_size
41
+ @buffer.push(segment)
42
+ end
43
+ end
44
+
45
+ def clear_queue
46
+ @buffer.clear
47
+ end
48
+
49
+ def close_queue
50
+ @mutex.synchronize do
51
+ @buffer.close
52
+ @closed = true
53
+ end
54
+ end
55
+
56
+ def closed?
57
+ @closed
58
+ end
59
+
60
+ def stream_data
61
+ begin
62
+ segment = @buffer.pop(false)
63
+ rescue ThreadError
64
+ return nil
65
+ end
66
+
67
+ Enumerator.new do |yie|
68
+ yie << generate_segment(segment) unless segment.nil?
69
+ end
70
+ end
71
+
72
+ def generate_segment(segment)
73
+ SegmentObject.new(
74
+ traceId: segment.related_traces[0].to_s,
75
+ traceSegmentId: segment.segment_id.to_s,
76
+ service: @config[:service_name],
77
+ serviceInstance: @config[:instance_name],
78
+ spans: segment.spans.map do |span|
79
+ SpanObject.new(
80
+ spanId: span.span_id,
81
+ parentSpanId: span.parent_id,
82
+ startTime: span.start_time,
83
+ endTime: span.end_time,
84
+ operationName: span.operation,
85
+ peer: span.peer,
86
+ spanType: Tracing.find_mapping(Tracing::Kind, span.kind),
87
+ spanLayer: span.layer,
88
+ componentId: span.component,
89
+ refs: span.refs.select { |ref| ref.trace_id }.map do |ref|
90
+ SegmentReference.new(
91
+ refType: ref.ref_type == 'CrossProcess' ? 0 : 1,
92
+ traceId: ref.trace_id,
93
+ parentTraceSegmentId: ref.segment_id,
94
+ parentSpanId: ref.span_id,
95
+ parentService: ref.service,
96
+ parentServiceInstance: ref.service_instance,
97
+ parentEndpoint: ref.endpoint,
98
+ networkAddressUsedAtPeer: ref.peer
99
+ )
100
+ end,
101
+ tags: span.tags_item
102
+ )
103
+ end
104
+ )
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,114 @@
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 'proto'
17
+ require_relative '../../tracing/constants'
18
+
19
+ module Skywalking
20
+ module Reporter
21
+ module Client
22
+ class GrpcClient
23
+ class ManagementServiceGrpc
24
+ include Log::Logging
25
+
26
+ def initialize(config)
27
+ @config = config
28
+ @management_service ||= ManagementServiceStub.new(
29
+ @config[:collector_backend_service],
30
+ :this_channel_is_insecure
31
+ )
32
+ end
33
+
34
+ def report_instance_properties
35
+ begin
36
+ req = InstanceProperties.new(
37
+ service: @config[:service_name],
38
+ serviceInstance: @config[:instance_name],
39
+ properties: gen_service_instance
40
+ )
41
+
42
+ @management_service.report_instance_properties(req)
43
+ rescue Exception => e
44
+ error "Error to report instance properties: #{e.message}"
45
+ end
46
+ end
47
+
48
+ def report_heartbeat
49
+ begin
50
+ req = InstancePingPkg.new(
51
+ service: @config[:service_name],
52
+ serviceInstance: @config[:instance_name]
53
+ )
54
+
55
+ @management_service.keep_alive(req)
56
+ rescue => e
57
+ error "Error to connect SkyWalking APM: #{e.message}"
58
+ end
59
+ end
60
+
61
+ def gen_service_instance
62
+ props = []
63
+
64
+ begin
65
+ props.push(
66
+ { key: 'language', value: 'ruby' },
67
+ { key: 'OS Name', value: RbConfig::CONFIG['host_os'] },
68
+ { key: 'Process No.', value: Process.pid.to_s },
69
+ { key: 'hostname', value: Socket.gethostname },
70
+ { key: 'ipv4', value: Socket.ip_address_list.select(&:ipv4?).map(&:ip_address).join('; ') },
71
+ { key: 'ruby_engine', value: RUBY_ENGINE },
72
+ { key: 'ruby_version', value: RUBY_VERSION }
73
+ )
74
+ rescue => e
75
+ warn "Failed to get local environment information: #{e.message}"
76
+ props = [{ key: 'language', value: 'ruby' }, { key: 'Process No.', value: Process.pid.to_s }]
77
+ end
78
+
79
+ namespace = @config[:namespace]
80
+ props << { key: 'namespace', value: namespace } if namespace
81
+
82
+ instance_properties_json = @config[:instance_properties_json]
83
+ if instance_properties_json && !instance_properties_json.empty?
84
+ json_properties = JSON.parse(instance_properties_json)
85
+ json_properties.each do |key, value|
86
+ props << { key: key, value: value }
87
+ end
88
+ end
89
+
90
+ props
91
+ end
92
+ end
93
+
94
+ class TraceSegmentReportServiceGrpc
95
+ include Log::Logging
96
+
97
+ def initialize(config)
98
+ @config = config
99
+ @trace_service ||= TraceSegmentReportServiceStub.new(
100
+ @config[:collector_backend_service],
101
+ :this_channel_is_insecure
102
+ )
103
+ end
104
+
105
+ def report_segment(enumerator)
106
+ @trace_service.collect(enumerator)
107
+ rescue Exception => e
108
+ error "Error to report trace segment: #{e.message}}"
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,29 @@
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 '../../proto/management/Management_services_pb'
17
+ require_relative '../../proto/language-agent/Tracing_services_pb'
18
+ require_relative '../../proto/language-agent/Tracing_pb'
19
+
20
+ module Skywalking
21
+ ManagementServiceStub = Skywalking::V3::ManagementService::Stub
22
+ InstanceProperties = Skywalking::V3::InstanceProperties
23
+ InstancePingPkg = Skywalking::V3::InstancePingPkg
24
+ TraceSegmentReportServiceStub = Skywalking::V3::TraceSegmentReportService::Stub
25
+ SegmentObject = Skywalking::V3::SegmentObject
26
+ SpanObject = Skywalking::V3::SpanObject
27
+ SegmentReference = Skywalking::V3::SegmentReference
28
+ KeyStringValuePair = Skywalking::V3::KeyStringValuePair
29
+ end