mnemosyne-ruby 1.14.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a1ccbc2b8a4f823ec3a848242e53f7b2a4fbd9001de8dda44a70011a90e8bbc
4
- data.tar.gz: 58ee31014f79ca2a7c36f7d19625f2e8c81f1298276733ed37aa5296a420064e
3
+ metadata.gz: 0366be612fd9619593a970098205515b3e361bca87359e4f52d44f0fb2324f35
4
+ data.tar.gz: ba0c6a47f4fa471fbfee289f60992c75c6b1dff50380134a4c3f4568436c8a16
5
5
  SHA512:
6
- metadata.gz: b9ec274a32fb1dfe5e9083b252246ff32a670de630d53f2bdb74e162d354d8b1fe314fe9a946fd70e70c309bfb7c7c1936d082460148102e8bde87d8c96158c2
7
- data.tar.gz: 9fffad92d4957da1df5b6a7fe725bf728404716d349db348f85dff77c52730de4a8fcafb750f98d234c0cf90031a804da9a29ab7ebd928d7a84480e0cea6069f
6
+ metadata.gz: aabbd8356edee9ca7ddca04641c5623f6c164679145d9f8ac91d7fab8fc7a0647e9d026603f45677bdfb996d1d414889537e4ad46b1cae12d7d5401633da31dd
7
+ data.tar.gz: 401dea26b2ab32e8e55ae34f3b168657a1123415aed59eb4c5883fbcf39b60c8b7b2cea7b17a61691850d1eed44c391bfbd463265b9503139f94f5f244db1338
@@ -6,7 +6,7 @@ on:
6
6
  jobs:
7
7
  rubocop:
8
8
  name: rubocop
9
- runs-on: ubuntu-20.04
9
+ runs-on: ubuntu-22.04
10
10
 
11
11
  env:
12
12
  BUNDLE_WITHOUT: development test
@@ -6,7 +6,7 @@ on:
6
6
  jobs:
7
7
  test:
8
8
  name: Ruby ${{ matrix.ruby }} / ${{ matrix.suite }}
9
- runs-on: ubuntu-20.04
9
+ runs-on: ubuntu-22.04
10
10
 
11
11
  strategy:
12
12
  fail-fast: false
@@ -27,6 +27,7 @@ jobs:
27
27
  - rails-6.1
28
28
  - rails-7.0
29
29
  - redis-4.0
30
+ - redis-5.0
30
31
  - restify
31
32
  - sidekiq-5
32
33
  - sidekiq-6
@@ -61,6 +62,9 @@ jobs:
61
62
  - suite: redis-4.0
62
63
  spec: --tag probe:redis
63
64
  gemfile: gemfiles/redis_40.gemfile
65
+ - suite: redis-5.0
66
+ spec: --tag probe:redis
67
+ gemfile: gemfiles/redis_50.gemfile
64
68
  - suite: restify
65
69
  spec: --tag probe:restify
66
70
  gemfile: gemfiles/core.gemfile
data/.gitignore CHANGED
@@ -4,6 +4,8 @@
4
4
  /coverage/
5
5
  /doc/
6
6
  /Gemfile.lock
7
+ /gemfiles/.bundle/
8
+ /log/
7
9
  /pkg/
8
10
  /spec/examples.txt
9
11
  /spec/reports/
data/Appraisals CHANGED
@@ -56,29 +56,19 @@ appraise 'rails-52' do
56
56
  end
57
57
  end
58
58
 
59
- appraise 'rails-51' do
60
- remove_gem 'rubocop'
61
-
62
- group :test do
63
- gem 'rails', '~> 5.1.0'
64
- gem 'sqlite3', '~> 1.4'
65
- end
66
- end
67
-
68
- appraise 'rails-50' do
59
+ appraise 'redis-40' do
69
60
  remove_gem 'rubocop'
70
61
 
71
62
  group :test do
72
- gem 'rails', '~> 5.0.0'
73
- gem 'sqlite3', '~> 1.3.6'
63
+ gem 'redis', '~> 4.0'
74
64
  end
75
65
  end
76
66
 
77
- appraise 'redis-40' do
67
+ appraise 'redis-50' do
78
68
  remove_gem 'rubocop'
79
69
 
80
70
  group :test do
81
- gem 'redis', '~> 4.0'
71
+ gem 'redis', '~> 5.0'
82
72
  end
83
73
  end
84
74
 
data/CHANGELOG.md CHANGED
@@ -4,27 +4,27 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## Unreleased
7
+ ## [Unreleased]
8
8
 
9
- ---
9
+ ## [1.15.0] - 2023-08-23
10
10
 
11
- ### New
11
+ ### Added
12
12
 
13
- ### Changes
13
+ - Support for `redis` gem v5+
14
14
 
15
- ### Fixes
15
+ ### Fixed
16
16
 
17
- ### Breaks
17
+ - Method signature for `#publish` in MSGR probe
18
18
 
19
19
  ## [1.14.0] - (2023-07-31)
20
20
 
21
- ### New
21
+ ### Added
22
22
 
23
23
  - Tests with Ruby 3.2
24
24
 
25
25
  ### Changed
26
26
 
27
- - Replace reprecated `!render.view_component` hook with `render.view_component`
27
+ - Replace deprecated `!render.view_component` hook with `render.view_component`
28
28
  - Removed tests for Rails 5.0 and 5.1
29
29
 
30
30
  ## [1.13.0] - 2022-04-14
@@ -192,6 +192,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
192
192
 
193
193
  - Add platform identifier
194
194
 
195
+ [Unreleased]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.15.0...HEAD
196
+ [1.15.0]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.14.0...v1.15.0
195
197
  [1.14.0]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.14.0...v1.13.0
196
198
  [1.13.0]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.13.0...v1.12.1
197
199
  [1.12.1]: https://github.com/mnemosyne-mon/mnemosyne-ruby/compare/v1.12.1...v1.12.0
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  gem 'rake', '~> 13.0'
9
- gem 'rubocop', '~> 1.54.0'
9
+ gem 'rubocop', '~> 1.56.0'
10
10
 
11
11
  group :test do
12
12
  gem 'rspec', '~> 3.6'
@@ -0,0 +1,27 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+
7
+ group :test do
8
+ gem "rspec", "~> 3.6"
9
+ gem "timecop", "~> 0.9.1"
10
+ gem "faraday"
11
+ gem "msgr"
12
+ gem "rails"
13
+ gem "redis", "~> 5.0"
14
+ gem "restify"
15
+ gem "sidekiq"
16
+ gem "sqlite3"
17
+ gem "webmock"
18
+ end
19
+
20
+ group :development do
21
+ gem "appraisal"
22
+ gem "rake-release", "~> 1.3.0"
23
+ gem "pry", require: false
24
+ gem "pry-byebug", require: false
25
+ end
26
+
27
+ gemspec path: "../"
@@ -13,7 +13,7 @@ module Mnemosyne
13
13
  end
14
14
 
15
15
  module Instrumentation
16
- def publish(payload, **options)
16
+ def publish(payload, options = {})
17
17
  if (trace = ::Mnemosyne::Instrumenter.current_trace)
18
18
  meta = {}
19
19
  span = ::Mnemosyne::Span.new(NAME, meta: meta)
@@ -6,121 +6,147 @@ module Mnemosyne
6
6
  module Command
7
7
  class Probe < ::Mnemosyne::Probe
8
8
  def setup
9
- ::Redis::Client.prepend ClientPatch
9
+ if Gem::Version.new(::Redis::VERSION) >= Gem::Version.new('5')
10
+ ::RedisClient.register Instrumentation
11
+ else
12
+ ::Redis::Client.prepend ClientPatch
13
+ end
10
14
  end
11
15
 
12
- module ClientPatch
13
- def process(commands)
14
- trace = ::Mnemosyne::Instrumenter.current_trace
15
- return super unless trace
16
+ module Instrumentation
17
+ def call(command, redis_config)
18
+ Instrumentation.instrument([command], client.server_url) { super }
19
+ end
16
20
 
17
- span = ::Mnemosyne::Span.new 'db.query.redis',
18
- meta: extract_span_meta(commands)
21
+ def call_pipelined(commands, redis_config)
22
+ Instrumentation.instrument(commands, client.server_url) { super }
23
+ end
24
+
25
+ class << self
26
+ def instrument(commands, server_url)
27
+ trace = ::Mnemosyne::Instrumenter.current_trace
28
+ return yield unless trace
19
29
 
20
- span.start!
30
+ span = ::Mnemosyne::Span.new 'db.query.redis',
31
+ meta: extract_span_meta(commands, server_url)
21
32
 
22
- super.tap do |retval|
23
- span.meta[:error] = retval.message if retval.is_a?(::Redis::CommandError)
33
+ span.start!
24
34
 
25
- trace << span.finish!
35
+ begin
36
+ yield.tap do |retval|
37
+ span.meta[:error] = retval.message if retval.is_a?(::Redis::CommandError)
38
+
39
+ trace << span.finish!
40
+ end
41
+ rescue StandardError => e
42
+ span.meta[:error] = e.message
43
+ trace << span.finish!
44
+ raise
45
+ end
26
46
  end
27
- end
28
47
 
29
- private
48
+ private
30
49
 
31
- def extract_span_meta(commands)
32
- {
33
- server: id,
50
+ def extract_span_meta(commands, server_url)
51
+ {
52
+ server: server_url,
34
53
 
35
- # Each command is an array, consisting of the command name and any
36
- # arguments. We are only interested in the command name.
37
- commands: extract_command_names(commands),
54
+ # Each command is an array, consisting of the command name and any
55
+ # arguments. We are only interested in the command name.
56
+ commands: extract_command_names(commands),
38
57
 
39
- # If there are multiple commands, that must mean they were pipelined
40
- # (i.e. run in parallel).
41
- pipelined: commands.length > 1
42
- }
43
- end
58
+ # If there are multiple commands, that must mean they were pipelined
59
+ # (i.e. run in parallel).
60
+ pipelined: commands.length > 1
61
+ }
62
+ end
44
63
 
45
- def extract_command_names(commands)
46
- commands.map do |c|
47
- # Depending on how the methods on the Redis gem are called,
48
- # there may be an additional level of nesting.
49
- c = c[0] if c[0].is_a?(Array)
64
+ def extract_command_names(commands)
65
+ commands.map do |c|
66
+ # Depending on how the methods on the Redis gem are called,
67
+ # there may be an additional level of nesting.
68
+ c = c[0] if c[0].is_a?(Array)
50
69
 
51
- # For some commands, we also extract *some* of the arguments.
52
- name, args = parse_name_and_args(c)
70
+ # For some commands, we also extract *some* of the arguments.
71
+ name, args = parse_name_and_args(c)
72
+
73
+ "#{name} #{args}".strip
74
+ end.join("\n")
75
+ end
53
76
 
54
- "#{name} #{args}".strip
55
- end.join("\n")
77
+ ##
78
+ # A map of known commands to the arguments (identified by position)
79
+ # that should be included verbatim in the metadata. Arguments not
80
+ # listed here will be replaced by a "?" character.
81
+ #
82
+ # The value can be a list of safe argument indices, or "*" (all).
83
+ #
84
+ KNOWN_ARGUMENTS = {
85
+ 'BLPOP' => '*',
86
+ 'BRPOP' => '*',
87
+ 'EVALSHA' => [0, 1],
88
+ 'EXISTS' => '*',
89
+ 'EXPIRE' => '*',
90
+ 'GET' => '*',
91
+ 'HGET' => '*',
92
+ 'HGETALL' => '*',
93
+ 'HMGET' => '*',
94
+ 'HMSET' => [0, 1],
95
+ 'HSCAN' => '*',
96
+ 'INCRBY' => '*',
97
+ 'LLEN' => '*',
98
+ 'LPUSH' => [0],
99
+ 'LRANGE' => '*',
100
+ 'LREM' => [0, 1],
101
+ 'MGET' => '*',
102
+ 'MSET' => [0],
103
+ 'RPUSH' => [0],
104
+ 'RPOP' => '*',
105
+ 'SADD' => [0],
106
+ 'SCARD' => '*',
107
+ 'SCAN' => '*',
108
+ 'SCRIPT LOAD' => [],
109
+ 'SET' => [0],
110
+ 'SREM' => [0],
111
+ 'SSCAN' => '*',
112
+ 'UNLINK' => '*',
113
+ 'ZADD' => [0],
114
+ 'ZCARD' => '*',
115
+ 'ZINCRBY' => [0, 1],
116
+ 'ZRANGE' => '*',
117
+ 'ZRANGEBYSCORE' => '*',
118
+ 'ZREM' => [0],
119
+ 'ZREMRANGEBYSCORE' => '*',
120
+ 'ZREVRANGE' => '*',
121
+ 'ZSCAN' => '*'
122
+ }.freeze
123
+
124
+ def parse_name_and_args(command)
125
+ command = command.dup
126
+
127
+ # Symbols and lower-case names are allowed
128
+ name = command.delete_at(0).to_s.upcase
129
+
130
+ allowed = KNOWN_ARGUMENTS[name] || []
131
+ args = case allowed
132
+ when '*' # All arguments considered safe
133
+ command
134
+ when Array # A list of allowed argument indices
135
+ command.each_with_index.map do |arg, index|
136
+ allowed.include?(index) ? arg : '?'
137
+ end
138
+ else # Unknown command - assume nothing is safe
139
+ Array.new(command.length, '?')
140
+ end.join(' ')
141
+
142
+ [name, args]
143
+ end
56
144
  end
145
+ end
57
146
 
58
- ##
59
- # A map of known commands to the arguments (identified by position)
60
- # that should be included verbatim in the metadata. Arguments not
61
- # listed here will be replaced by a "?" character.
62
- #
63
- # The value can be a list of safe argument indices, or "*" (all).
64
- #
65
- KNOWN_ARGUMENTS = {
66
- 'BLPOP' => '*',
67
- 'BRPOP' => '*',
68
- 'EVALSHA' => [0, 1],
69
- 'EXISTS' => '*',
70
- 'EXPIRE' => '*',
71
- 'GET' => '*',
72
- 'HGET' => '*',
73
- 'HGETALL' => '*',
74
- 'HMGET' => '*',
75
- 'HMSET' => [0, 1],
76
- 'HSCAN' => '*',
77
- 'INCRBY' => '*',
78
- 'LLEN' => '*',
79
- 'LPUSH' => [0],
80
- 'LRANGE' => '*',
81
- 'LREM' => [0, 1],
82
- 'MGET' => '*',
83
- 'MSET' => [0],
84
- 'RPUSH' => [0],
85
- 'RPOP' => '*',
86
- 'SADD' => [0],
87
- 'SCARD' => '*',
88
- 'SCAN' => '*',
89
- 'SCRIPT LOAD' => [],
90
- 'SET' => [0],
91
- 'SREM' => [0],
92
- 'SSCAN' => '*',
93
- 'UNLINK' => '*',
94
- 'ZADD' => [0],
95
- 'ZCARD' => '*',
96
- 'ZINCRBY' => [0, 1],
97
- 'ZRANGE' => '*',
98
- 'ZRANGEBYSCORE' => '*',
99
- 'ZREM' => [0],
100
- 'ZREMRANGEBYSCORE' => '*',
101
- 'ZREVRANGE' => '*',
102
- 'ZSCAN' => '*'
103
- }.freeze
104
-
105
- def parse_name_and_args(command)
106
- command = command.dup
107
-
108
- # Symbols and lower-case names are allowed
109
- name = command.delete_at(0).to_s.upcase
110
-
111
- allowed = KNOWN_ARGUMENTS[name] || []
112
- args = case allowed
113
- when '*' # All arguments considered safe
114
- command
115
- when Array # A list of allowed argument indices
116
- command.each_with_index.map do |arg, index|
117
- allowed.include?(index) ? arg : '?'
118
- end
119
- else # Unknown command - assume nothing is safe
120
- Array.new(command.length, '?')
121
- end.join(' ')
122
-
123
- [name, args]
147
+ module ClientPatch
148
+ def process(commands)
149
+ Instrumentation.instrument(commands, id) { super }
124
150
  end
125
151
  end
126
152
  end
@@ -3,7 +3,7 @@
3
3
  module Mnemosyne
4
4
  module VERSION
5
5
  MAJOR = 1
6
- MINOR = 14
6
+ MINOR = 15
7
7
  PATCH = 0
8
8
  STAGE = nil
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mnemosyne-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-31 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -67,6 +67,7 @@ files:
67
67
  - gemfiles/rails_61.gemfile
68
68
  - gemfiles/rails_70.gemfile
69
69
  - gemfiles/redis_40.gemfile
70
+ - gemfiles/redis_50.gemfile
70
71
  - gemfiles/sidekiq_50.gemfile
71
72
  - gemfiles/sidekiq_60.gemfile
72
73
  - lib/mnemosyne-ruby.rb
@@ -134,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
135
  - !ruby/object:Gem::Version
135
136
  version: '0'
136
137
  requirements: []
137
- rubygems_version: 3.4.10
138
+ rubygems_version: 3.4.18
138
139
  signing_key:
139
140
  specification_version: 4
140
141
  summary: Ruby/Rails client for Mnemosyne APM