skywalking 0.0.0.beta1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 440bef4a38e67a74f5da465bfe3e7f0482631f7371d89f8d2848c7519f37c1de
4
- data.tar.gz: b536aadb8f8eb25357bf20c2bf16d40c868c2068fbdc5b0559794e3a4e9c9839
3
+ metadata.gz: '058cbfc2e9df3398ba09f1a8da70408f7e96f8566f13bb28ea53aa7d77da899b'
4
+ data.tar.gz: a33b749f8113734ca347028255fb8bbc560f0c0a1516dcd117389e0cd74cdd88
5
5
  SHA512:
6
- metadata.gz: 59b5fefb96f307c1e70d8d975c8c962b69c0410051a2f2951a69f221b17ea896ffde723d224a5a6cbb11eed0b6c51bf74064c7a6e05db72d36e663309b1560fd
7
- data.tar.gz: 021b8f374d2f6a22b833b8dddae9ea1cc497859885098d8f04274546409d461d2904d32c22af6cf8347e09ffc51b9d0580739be8fda604e8415feff59b49631a
6
+ metadata.gz: 8f389f316e1b73cb05b4dde7d792442a9a7e845401118d7eda452e5d8486d442d9a4c778891d33bcc4540f8189b79a7a17bf230c461d7c294c50c89d89664c1a
7
+ data.tar.gz: 640b7164490de817255ef9699f3cce48eb7f90285901d5e0e54818d6a35eb61ce660df59a9039e62656133a2a0940482b7c444480a575ddb77cdf35d77b1e997
data/CHANGELOG.md CHANGED
@@ -7,12 +7,13 @@ Release Notes.
7
7
  #### Features
8
8
  - Initialize the ruby agent core.
9
9
  - Implement e2e tests.
10
- - Add docs.
11
10
 
12
11
  #### Plugins
13
12
  * Support [Sinatra](https://github.com/sinatra/sinatra)
14
13
  * Support [redis-rb](https://github.com/redis/redis-rb)
15
14
  * Support [net-http](https://github.com/ruby/net-http)
15
+ * Support [memcached](https://github.com/petergoldstein/dalli)
16
+ * Support [elasticsearch](https://github.com/elastic/elasticsearch-ruby)
16
17
 
17
18
  #### Documentation
18
19
  * Initialize the documentation.
data/README.md CHANGED
@@ -8,6 +8,9 @@ Apache SkyWalking Ruby Agent
8
8
  **SkyWalking**: an APM(application performance monitor) system, especially designed for
9
9
  microservices, cloud native and container-based (Docker, Kubernetes, Mesos) architectures.
10
10
 
11
+ # Documentation
12
+ - [Official documentation](https://skywalking.apache.org/docs/#RubyAgent)
13
+
11
14
  ## Contact Us
12
15
  * Submit [an issue](https://github.com/apache/skywalking/issues/new) by using [Ruby] as title prefix.
13
16
  * Mail list: **dev@skywalking.apache.org**. Mail to `dev-subscribe@skywalking.apache.org`, follow the reply to subscribe the mail list.
@@ -3,8 +3,10 @@
3
3
  The following plugins provide the distributed tracing capability, and the OAP backend would analyze the topology and
4
4
  metrics based on the tracing data.
5
5
 
6
- | Library | Version | Plugin Name |
7
- |:----------------------------------------------|:---------|:------------|
8
- | [redis](https://github.com/redis/redis-rb) | ~> 5.0 | `redis` |
9
- | [net-http](https://github.com/ruby/net-http) | ~> 0.6.0 | `net_http` |
10
- | [sinatra](https://github.com/sinatra/sinatra) | ~> 4.1 | `sinatra` |
6
+ | Library | Version | Plugin Name |
7
+ |:---------------------------------------------------------------|:---------|:----------------|
8
+ | [redis](https://github.com/redis/redis-rb) | ~> 5.0 | `redis5` |
9
+ | [net-http](https://github.com/ruby/net-http) | ~> 0.6.0 | `net_http` |
10
+ | [sinatra](https://github.com/sinatra/sinatra) | ~> 4.1 | `sinatra` |
11
+ | [memcached](https://github.com/petergoldstein/dalli) | ~> 3.2 | `memcached` |
12
+ | [elasticsearch](https://github.com/elastic/elasticsearch-ruby) | ~> 8.0.0 | `elasticsearch` |
@@ -97,7 +97,7 @@ The following lists all the configuration options:
97
97
  | log_file_name | SW_AGENT_LOG_FILE_NAME | skywalking | The name of the log file. |
98
98
  | log_file_path | SW_AGENT_LOG_FILE_PATH | Not set | The path to the log file. |
99
99
  | log_level | SW_AGENT_LOG_LEVEL | info | The log level. |
100
- | disable_plugins | SW_AGENT_DISABLE_PLUGINS | Not set | The plugins to disable. |
100
+ | disable_plugins | SW_AGENT_DISABLE_PLUGINS | Not set | The plugins to disable, multiple names should be split by comma, e.g. 'redis5,elasticsearch'. |
101
101
  | report_protocol | SW_AGENT_REPORT_PROTOCOL | grpc | The protocol to use for reporting. |
102
102
  | re_ignore_operation | SW_AGENT_RE_IGNORE_OPERATION | Not set | Ignore specific URL paths. |
103
103
  | instance_properties_json | SW_AGENT_INSTANCE_PROPERTIES_JSON | Not set | A custom JSON string to be reported as service instance properties, e.g. `{"key": "value"}`. |
@@ -67,7 +67,7 @@ module Skywalking
67
67
  :disable_plugins => {
68
68
  type: :string,
69
69
  default: '',
70
- desc: 'The plugins to disable'
70
+ desc: "The plugins to disable, multiple names should be split by comma, e.g. 'redis5,elasticsearch'"
71
71
  },
72
72
  :report_protocol => {
73
73
  type: :string,
@@ -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
+ module Skywalking
17
+ module Plugins
18
+ class Elasticsearch < PluginsManager::SWPlugin
19
+ def plugin_valid?
20
+ defined?(::Elasticsearch)
21
+ end
22
+
23
+ def install
24
+ inst_target = if defined?(::Elastic::Transport::Client)
25
+ ::Elastic::Transport::Client
26
+ elsif defined?(::Elasticsearch::Transport::Client)
27
+ ::Elasticsearch::Transport::Client
28
+ end
29
+
30
+ inst_target.class_eval do
31
+ def perform_request_with_skywalking(method, path, *args, &block)
32
+ peer_info = transport.hosts.first
33
+ db_statement = [{ params: args&.[](0) }]
34
+ unless args[1].nil? || args[1].empty?
35
+ db_statement << { body: args[1] }
36
+ end
37
+
38
+ Tracing::ContextManager.new_exit_span(
39
+ operation: "Elasticsearch/#{method}/#{path}",
40
+ peer: "#{peer_info[:protocol]}://#{peer_info[:host]}:#{peer_info[:port]}",
41
+ component: Tracing::Component::Elasticsearch
42
+ ) do |span|
43
+ span&.tag(Tracing::TagDbType.new("Elasticsearch"))
44
+ span&.tag(Tracing::TagDbStatement.new(db_statement))
45
+ span&.layer = Tracing::Layer::Database
46
+
47
+ zuper_perform_request(method, path, *args, &block)
48
+ rescue
49
+ span&.error_occurred = true
50
+ end
51
+ end
52
+
53
+ alias_method :zuper_perform_request, :perform_request
54
+ alias_method :perform_request, :perform_request_with_skywalking
55
+ end
56
+ end
57
+
58
+ register :elasticsearch
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,74 @@
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 Skywalking
17
+ module Plugins
18
+ module MemcachedIntercept
19
+ def self.included(klass)
20
+ supported_method =
21
+ [:add, :append, :delete, :cas, :incr, :increment, :prepend, :replace, :set, :get, :fetch]
22
+ .select do |method_name|
23
+ klass.method_defined?(method_name) || klass.private_method_defined?(method_name)
24
+ end
25
+
26
+ supported_method.each do |method_name|
27
+ zuper_method = :"zuper_#{method_name}"
28
+ method_with_skywalking = :"#{method_name}_with_skywalking"
29
+
30
+ klass.class_eval do
31
+ define_method(method_with_skywalking) do |*args, &block|
32
+ cache_key = args[0].to_s if args.length && !args[0].is_a?(Array)
33
+ Tracing::ContextManager.new_exit_span(
34
+ operation: "Memcached/#{method_name}",
35
+ peer: @normalized_servers.join(','),
36
+ component: Tracing::Component::Memcached
37
+ ) do |span|
38
+ span&.layer = Tracing::Layer::Cache
39
+ span&.tag(Tracing::TagCacheType.new("Memcached"))
40
+ span&.tag(Tracing::TagCacheKey.new(cache_key))
41
+
42
+ resp = __send__(zuper_method, *args, &block)
43
+ if method_name == :get && args.length && args[0].instance_of?(String)
44
+ span&.tag(Tracing::TagCacheMiss.new(resp.nil?))
45
+ end
46
+
47
+ resp
48
+ rescue
49
+ span&.error_occurred = true
50
+ end
51
+ end
52
+
53
+ alias_method zuper_method, method_name
54
+ alias_method method_name, method_with_skywalking
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ class Memcached < PluginsManager::SWPlugin
61
+ def plugin_valid?
62
+ defined?(::Dalli::Client)
63
+ end
64
+
65
+ def install
66
+ ::Dalli::Client.class_eval do
67
+ include Skywalking::Plugins::MemcachedIntercept
68
+ end
69
+ end
70
+
71
+ register :memcached
72
+ end
73
+ end
74
+ end
@@ -35,7 +35,7 @@ module Skywalking
35
35
  Tracing::ContextManager.new_exit_span(
36
36
  operation: "#{method}:#{req_info}",
37
37
  peer: host,
38
- component: Tracing::Component::Http
38
+ component: Tracing::Component::HttpClient
39
39
  ) do |span|
40
40
  span&.tag(Tracing::TagHttpMethod.new(method))
41
41
  span&.tag(Tracing::TagHttpURL.new(uri))
@@ -30,7 +30,11 @@ module Skywalking
30
30
  span&.tag(Tracing::TagCacheOp.new(operation))
31
31
  span&.layer = Tracing::Layer::Cache
32
32
 
33
- super(args, &block)
33
+ begin
34
+ super(args, &block)
35
+ rescue
36
+ span&.error_occurred = true
37
+ end
34
38
  end
35
39
  end
36
40
 
@@ -21,13 +21,12 @@ module Skywalking
21
21
  req_method = @request.request_method if @request.respond_to?(:request_method)
22
22
  carrier = Tracing::Carrier.new
23
23
  carrier.each do |item|
24
- item.val = request.env[item.key.capitalize] if request.env[item.key.capitalize]
24
+ item.value = request.env["HTTP_#{item.key.upcase}"]
25
25
  end
26
26
 
27
27
  Tracing::ContextManager.new_entry_span(
28
28
  operation: "#{req_method}:#{request.env['REQUEST_URI']}",
29
- carrier: carrier,
30
- inherit: Tracing::Component::General
29
+ carrier: carrier
31
30
  ) do |span|
32
31
  span&.tag(Tracing::TagHttpMethod.new(req_method))
33
32
  span&.tag(Tracing::TagHttpURL.new(request.env['REQUEST_URI']))
@@ -36,6 +35,8 @@ module Skywalking
36
35
  span&.component = Tracing::Component::Sinatra
37
36
 
38
37
  super(*args, &block)
38
+ rescue
39
+ span&.error_occurred = true
39
40
  end
40
41
  end
41
42
  end
@@ -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
@@ -21,7 +21,7 @@ module Skywalking
21
21
  class Carrier < CarrierItem
22
22
  attr_reader :trace_id, :correlation_carrier, :service_instance,
23
23
  :endpoint, :segment_id, :span_id,
24
- :peer, :items, :iter_index
24
+ :peer, :items, :iter_index, :service
25
25
 
26
26
  def initialize(
27
27
  trace_id: '',
@@ -17,8 +17,10 @@ module Skywalking
17
17
  module Tracing
18
18
  module Component
19
19
  Unknown = 0
20
- Http = 2
20
+ HttpClient = 2
21
21
  Redis = 7
22
+ Memcached = 20
23
+ Elasticsearch = 47
22
24
  General = 12000
23
25
  Sinatra = 12001
24
26
  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
@@ -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
@@ -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
@@ -53,6 +53,13 @@ module Skywalking
53
53
  end
54
54
  end
55
55
 
56
+ class TagDbStatement < Tag
57
+ def initialize(val)
58
+ super
59
+ @key = 'db.statement'
60
+ end
61
+ end
62
+
56
63
  class TagCacheType < Tag
57
64
  def initialize(val)
58
65
  super
@@ -80,5 +87,12 @@ module Skywalking
80
87
  @key = 'cache.key'
81
88
  end
82
89
  end
90
+
91
+ class TagCacheMiss < Tag
92
+ def initialize(val)
93
+ super
94
+ @key = 'cache.miss'
95
+ end
96
+ end
83
97
  end
84
98
  end
@@ -14,5 +14,5 @@
14
14
  # limitations under the License.
15
15
 
16
16
  module Skywalking
17
- VERSION = "0.0.0.beta1".freeze
17
+ VERSION = "0.0.0.beta2".freeze
18
18
  end
data/skywalking.gemspec CHANGED
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
42
42
  spec.require_paths = ['lib']
43
43
 
44
44
  # Communication with OAP
45
- spec.add_dependency 'grpc', '1.68.1'
45
+ spec.add_dependency 'grpc', '~> 1.68.0'
46
46
 
47
47
  # Base dev dependency
48
48
  spec.add_development_dependency 'bundler', '~> 2.0'
@@ -53,9 +53,6 @@ Gem::Specification.new do |spec|
53
53
  spec.add_development_dependency 'bigdecimal', '3.1.5'
54
54
 
55
55
  # E2E test dependency
56
- spec.add_development_dependency 'redis', '~> 5.0'
57
- spec.add_development_dependency 'sinatra', '~> 4.1'
58
56
  spec.add_development_dependency 'testcontainers-compose', '~> 0.2.0'
59
57
  spec.add_development_dependency 'faraday', '~> 2.12'
60
- spec.add_development_dependency 'rspec-wait', '~> 1.0'
61
58
  end
@@ -30,7 +30,7 @@ RSpec.shared_context 'compose' do
30
30
 
31
31
  before(:each) do
32
32
  compose.start
33
- compose.wait_for_http(url: client_url, timeout: 600)
33
+ compose.wait_for_http(url: client_url, timeout: 800)
34
34
  end
35
35
 
36
36
  after(:each) do
@@ -0,0 +1,72 @@
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
+ elasticsearch:
29
+ image: elasticsearch:8.0.0
30
+ hostname: elasticsearch
31
+ ports:
32
+ - "9200:9200"
33
+ environment:
34
+ - discovery.type=single-node
35
+ - bootstrap.memory_lock=true
36
+ - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
37
+ - xpack.security.enabled=false
38
+ networks:
39
+ - gem
40
+ healthcheck:
41
+ test: [ "CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1" ]
42
+ interval: 5s
43
+ timeout: 60s
44
+ retries: 120
45
+
46
+ service:
47
+ extends:
48
+ file: ../common/base-compose.yml
49
+ service: agent
50
+ ports:
51
+ - "8080:8080"
52
+ volumes:
53
+ - .:/app/spec/scenarios/elasticsearch
54
+ environment:
55
+ SW_AGENT_SERVICE_NAME: "elasticsearch"
56
+ healthcheck:
57
+ test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/8080" ]
58
+ interval: 5s
59
+ timeout: 60s
60
+ retries: 120
61
+ entrypoint:
62
+ - "sh"
63
+ - "-c"
64
+ - "gem install sinatra rackup puma elasticsearch && ruby /app/spec/scenarios/elasticsearch/elasticsearch.rb"
65
+ depends_on:
66
+ oap:
67
+ condition: service_healthy
68
+ networks:
69
+ - gem
70
+
71
+ networks:
72
+ gem:
@@ -0,0 +1,54 @@
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 'sinatra'
18
+ require 'elasticsearch'
19
+
20
+ Skywalking.start(disable_plugins: 'net_http')
21
+
22
+ def create_index(client)
23
+ client.indices.create(index: 'test_index', body: { mappings: { properties: { name: { type: 'text' } } } })
24
+ puts "Index created."
25
+ end
26
+
27
+ def add_document(client, id, name)
28
+ client.index(index: 'test_index', id: id, body: { name: name })
29
+ puts "Document added: #{id} => #{name}"
30
+ end
31
+
32
+ def get_document(client, id)
33
+ response = client.get(index: 'test_index', id: id)
34
+ puts "Document retrieved: #{response['_source']}"
35
+ rescue Elasticsearch::Transport::Transport::Errors::NotFound
36
+ puts "Document not found."
37
+ end
38
+
39
+ def delete_document(client, id)
40
+ client.delete(index: 'test_index', id: id)
41
+ puts "Document deleted: #{id}"
42
+ end
43
+
44
+ get "/execute" do
45
+ client = Elasticsearch::Client.new(hosts: ['http://elasticsearch:9200'], log: true,
46
+ transport_options: { request: { timeout: 5 } })
47
+ create_index(client)
48
+ add_document(client, '1', 'Document 1')
49
+ get_document(client, '1')
50
+ delete_document(client, '1')
51
+ end
52
+
53
+ set :bind, '0.0.0.0'
54
+ set :port, 8080
@@ -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 '../common/common_spec_helper'
17
+ require_relative '../common/compose_context'
18
+
19
+ RSpec.describe "Elasticsearch" do
20
+ include CommonSpecHelper
21
+ include_context 'compose'
22
+ include_context 'scenario value'
23
+
24
+ let(:root_dir) { File.expand_path(__dir__) }
25
+
26
+ it 'test elasticsearch plugin' do
27
+ test_plugin('elasticsearch')
28
+ end
29
+ end
@@ -0,0 +1,94 @@
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: elasticsearch
19
+ segmentSize: ge 1
20
+ segments:
21
+ - segmentId: not null
22
+ spans:
23
+ - operationName: Elasticsearch/PUT/test_index
24
+ parentSpanId: 0
25
+ spanId: 1
26
+ spanLayer: Database
27
+ startTime: gt 0
28
+ endTime: gt 0
29
+ componentId: 47
30
+ isError: false
31
+ spanType: Exit
32
+ peer: http://elasticsearch:9200
33
+ skipAnalysis: false
34
+ tags:
35
+ - { key: db.type, value: Elasticsearch }
36
+ - { key: db.statement, value: '[{:params=>{}}, {:body=>{:mappings=>{:properties=>{:name=>{:type=>"text"}}}}}]' }
37
+ - operationName: Elasticsearch/PUT/test_index/_doc/1
38
+ parentSpanId: 0
39
+ spanId: 2
40
+ spanLayer: Database
41
+ startTime: gt 0
42
+ endTime: gt 0
43
+ componentId: 47
44
+ isError: false
45
+ spanType: Exit
46
+ peer: http://elasticsearch:9200
47
+ skipAnalysis: false
48
+ tags:
49
+ - { key: db.type, value: Elasticsearch }
50
+ - { key: db.statement, value: '[{:params=>{}}, {:body=>{:name=>"Document 1"}}]' }
51
+ - operationName: Elasticsearch/GET/test_index/_doc/1
52
+ parentSpanId: 0
53
+ spanId: 3
54
+ spanLayer: Database
55
+ startTime: gt 0
56
+ endTime: gt 0
57
+ componentId: 47
58
+ isError: false
59
+ spanType: Exit
60
+ peer: http://elasticsearch:9200
61
+ skipAnalysis: false
62
+ tags:
63
+ - { key: db.type, value: Elasticsearch }
64
+ - { key: db.statement, value: '[{:params=>{}}]' }
65
+ - operationName: Elasticsearch/DELETE/test_index/_doc/1
66
+ parentSpanId: 0
67
+ spanId: 4
68
+ spanLayer: Database
69
+ startTime: gt 0
70
+ endTime: gt 0
71
+ componentId: 47
72
+ isError: false
73
+ spanType: Exit
74
+ peer: http://elasticsearch:9200
75
+ skipAnalysis: false
76
+ tags:
77
+ - { key: db.type, value: Elasticsearch }
78
+ - { key: db.statement, value: '[{:params=>{}}]' }
79
+ - operationName: GET:/execute
80
+ parentSpanId: -1
81
+ spanId: 0
82
+ spanLayer: Http
83
+ startTime: gt 0
84
+ endTime: gt 0
85
+ componentId: 12001
86
+ isError: false
87
+ spanType: Entry
88
+ peer: localhost:8080
89
+ skipAnalysis: false
90
+ tags:
91
+ - { key: http.method, value: GET }
92
+ - { key: http.url, value: /execute }
93
+ meterItems: [ ]
94
+ logItems: [ ]
@@ -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
+ memcached:
29
+ image: memcached:1.6
30
+ hostname: memcached
31
+ ports:
32
+ - "11211:11211"
33
+ networks:
34
+ - gem
35
+ healthcheck:
36
+ test: [ "CMD", "nc", "-z", "localhost", "11211" ]
37
+ interval: 5s
38
+ timeout: 60s
39
+ retries: 120
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/memcached
49
+ environment:
50
+ SW_AGENT_SERVICE_NAME: "memcached"
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 dalli && ruby /app/spec/scenarios/memcached/memcached.rb"
60
+ depends_on:
61
+ oap:
62
+ condition: service_healthy
63
+ networks:
64
+ - gem
65
+
66
+ networks:
67
+ gem:
@@ -0,0 +1,81 @@
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: memcached
19
+ segmentSize: ge 1
20
+ segments:
21
+ - segmentId: not null
22
+ spans:
23
+ - operationName: Memcached/set
24
+ parentSpanId: 0
25
+ spanId: 1
26
+ spanLayer: Cache
27
+ startTime: gt 0
28
+ endTime: gt 0
29
+ componentId: 20
30
+ isError: false
31
+ spanType: Exit
32
+ peer: memcached:11211
33
+ skipAnalysis: false
34
+ tags:
35
+ - {key: cache.type, value: Memcached}
36
+ - {key: cache.key, value: sw_key}
37
+ - operationName: Memcached/get
38
+ parentSpanId: 0
39
+ spanId: 2
40
+ spanLayer: Cache
41
+ startTime: gt 0
42
+ endTime: gt 0
43
+ componentId: 20
44
+ isError: false
45
+ spanType: Exit
46
+ peer: memcached:11211
47
+ skipAnalysis: false
48
+ tags:
49
+ - {key: cache.type, value: Memcached}
50
+ - {key: cache.key, value: sw_key}
51
+ - {key: cache.miss, value: 'false'}
52
+ - operationName: Memcached/delete
53
+ parentSpanId: 0
54
+ spanId: 3
55
+ spanLayer: Cache
56
+ startTime: gt 0
57
+ endTime: gt 0
58
+ componentId: 20
59
+ isError: false
60
+ spanType: Exit
61
+ peer: memcached:11211
62
+ skipAnalysis: false
63
+ tags:
64
+ - {key: cache.type, value: Memcached}
65
+ - {key: cache.key, value: sw_key}
66
+ - operationName: GET:/execute
67
+ parentSpanId: -1
68
+ spanId: 0
69
+ spanLayer: Http
70
+ startTime: gt 0
71
+ endTime: gt 0
72
+ componentId: 12001
73
+ isError: false
74
+ spanType: Entry
75
+ peer: localhost:8080
76
+ skipAnalysis: false
77
+ tags:
78
+ - {key: http.method, value: GET}
79
+ - {key: http.url, value: /execute}
80
+ meterItems: []
81
+ logItems: []
@@ -0,0 +1,31 @@
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 'sinatra'
18
+ require 'dalli'
19
+
20
+ Skywalking.start
21
+
22
+ get "/execute" do
23
+ client = Dalli::Client.new('memcached:11211', { namespace: "sw", compress: true })
24
+ client.set('sw_key', 'sw_value')
25
+ value = client.get('sw_key')
26
+ p "The value for 'sw_key' is: #{value}"
27
+ client.delete('sw_key')
28
+ end
29
+
30
+ set :bind, '0.0.0.0'
31
+ set :port, 8080
@@ -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 '../common/common_spec_helper'
17
+ require_relative '../common/compose_context'
18
+
19
+ RSpec.describe "Memcached" do
20
+ include CommonSpecHelper
21
+ include_context 'compose'
22
+ include_context 'scenario value'
23
+
24
+ let(:root_dir) { File.expand_path(__dir__) }
25
+
26
+ it 'test memcached plugin' do
27
+ test_plugin('memcached')
28
+ end
29
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skywalking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.beta1
4
+ version: 0.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apache SkyWalking Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-15 00:00:00.000000000 Z
11
+ date: 2025-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.68.1
19
+ version: 1.68.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.68.1
26
+ version: 1.68.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,34 +108,6 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 3.1.5
111
- - !ruby/object:Gem::Dependency
112
- name: redis
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '5.0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '5.0'
125
- - !ruby/object:Gem::Dependency
126
- name: sinatra
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '4.1'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '4.1'
139
111
  - !ruby/object:Gem::Dependency
140
112
  name: testcontainers-compose
141
113
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +136,6 @@ dependencies:
164
136
  - - "~>"
165
137
  - !ruby/object:Gem::Version
166
138
  version: '2.12'
167
- - !ruby/object:Gem::Dependency
168
- name: rspec-wait
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '1.0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '1.0'
181
139
  description: The Ruby Agent for Apache SkyWalking
182
140
  email:
183
141
  - dev@skywalking.apache.org
@@ -214,6 +172,8 @@ files:
214
172
  - lib/skywalking/configuration.rb
215
173
  - lib/skywalking/environment.rb
216
174
  - lib/skywalking/log/logger.rb
175
+ - lib/skywalking/plugins/elasticsearch.rb
176
+ - lib/skywalking/plugins/memcached.rb
217
177
  - lib/skywalking/plugins/net_http.rb
218
178
  - lib/skywalking/plugins/redis5.rb
219
179
  - lib/skywalking/plugins/sinatra.rb
@@ -287,6 +247,14 @@ files:
287
247
  - spec/scenarios/common/common_spec_helper.rb
288
248
  - spec/scenarios/common/compose_context.rb
289
249
  - spec/scenarios/common/validator.rb
250
+ - spec/scenarios/elasticsearch/docker-compose.yml
251
+ - spec/scenarios/elasticsearch/elasticsearch.rb
252
+ - spec/scenarios/elasticsearch/elasticsearch_spec.rb
253
+ - spec/scenarios/elasticsearch/expected.yml
254
+ - spec/scenarios/memcached/docker-compose.yml
255
+ - spec/scenarios/memcached/expected.yml
256
+ - spec/scenarios/memcached/memcached.rb
257
+ - spec/scenarios/memcached/memcached_spec.rb
290
258
  - spec/scenarios/net_http/docker-compose.yml
291
259
  - spec/scenarios/net_http/expected.yml
292
260
  - spec/scenarios/net_http/net_http.rb