activerecord-instrumentation 0.4.0 → 0.5.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -3
- data/CHANGELOG.md +8 -1
- data/Gemfile +1 -2
- data/Gemfile.lock +18 -31
- data/activerecord-instrumentation.gemspec +0 -1
- data/lib/active_record/open_tracing/processor.rb +46 -2
- data/lib/active_record/open_tracing/version.rb +1 -1
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e9f37f60697581a35d5a32b14d2896666c0ece3f312f767a47343933f1524f6
|
4
|
+
data.tar.gz: 0b9d05827c6d68142d50e428244cd95867a8ed081379159edb575bae39bed399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67b7a415498e011891835dc73919dd32e51236538cf3892ad3e385509051ae13e0e40827516d4e7c00be25c406ee03d8ce126e495a7d9fc5a8ba0fa69b8cbe37
|
7
|
+
data.tar.gz: 986a1438a09c6f0a55d64921c2de7c10c4501cd0ce2345c2b430eb09b820ce30062e0c8420ef9a754f3b40b119e6d0b07d5238c2d34efaea272f811fc1974cf2
|
data/.circleci/config.yml
CHANGED
@@ -7,7 +7,7 @@ executors:
|
|
7
7
|
ruby-latest:
|
8
8
|
resource_class: small
|
9
9
|
docker:
|
10
|
-
- image: circleci/ruby:
|
10
|
+
- image: circleci/ruby:2.7
|
11
11
|
environment:
|
12
12
|
BUNDLE_VERSION: "~> 1.17"
|
13
13
|
|
@@ -45,7 +45,7 @@ jobs:
|
|
45
45
|
- v1-bundle-{{ checksum "Gemfile.lock" }}-
|
46
46
|
- run:
|
47
47
|
name: Install Ruby Dependencies
|
48
|
-
command: bundle
|
48
|
+
command: bundle install --path=vendor/bundle # install every time so we don't have to package vendor/bundle with the gem
|
49
49
|
- save_cache:
|
50
50
|
key: v1-bundle-{{ checksum "Gemfile.lock" }}-
|
51
51
|
paths:
|
@@ -123,4 +123,3 @@ workflows:
|
|
123
123
|
requires:
|
124
124
|
- gem-build
|
125
125
|
context: artifact_publishing
|
126
|
-
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
## 0.5.1.pre 01/18/2022
|
5
|
+
* Trying to fix the publishing process
|
6
|
+
|
7
|
+
## 0.5.0 01/18/2022
|
8
|
+
* Added db.query_type and db.query_category tags
|
9
|
+
* Added forwards compatibility code for the connection_config for rails 6.2
|
10
|
+
|
4
11
|
## 0.4.0 04/28/2020
|
5
12
|
* Add SQL sanitizers
|
6
13
|
|
7
14
|
## 0.3.0 04/22/2020
|
8
15
|
* Set up build pipeline with circleci and gem-publisher
|
9
16
|
* Fixed linting issues
|
10
|
-
* Renamed gem to `activerecord-instrumentation`
|
17
|
+
* Renamed gem to `activerecord-instrumentation`
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,43 +1,37 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activerecord-instrumentation (0.
|
4
|
+
activerecord-instrumentation (0.5.1.pre)
|
5
5
|
activerecord
|
6
6
|
opentracing (~> 0.5)
|
7
7
|
|
8
8
|
GEM
|
9
|
-
remote: https://
|
9
|
+
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (6.
|
12
|
-
activesupport (= 6.
|
13
|
-
activerecord (6.
|
14
|
-
activemodel (= 6.
|
15
|
-
activesupport (= 6.
|
16
|
-
activesupport (6.
|
11
|
+
activemodel (6.1.4.4)
|
12
|
+
activesupport (= 6.1.4.4)
|
13
|
+
activerecord (6.1.4.4)
|
14
|
+
activemodel (= 6.1.4.4)
|
15
|
+
activesupport (= 6.1.4.4)
|
16
|
+
activesupport (6.1.4.4)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
-
i18n (>=
|
19
|
-
minitest (
|
20
|
-
tzinfo (~>
|
21
|
-
zeitwerk (~> 2.
|
18
|
+
i18n (>= 1.6, < 2)
|
19
|
+
minitest (>= 5.1)
|
20
|
+
tzinfo (~> 2.0)
|
21
|
+
zeitwerk (~> 2.3)
|
22
22
|
ast (2.4.0)
|
23
|
-
concurrent-ruby (1.1.
|
23
|
+
concurrent-ruby (1.1.9)
|
24
24
|
diff-lcs (1.3)
|
25
|
-
|
26
|
-
rubocop (~> 0.77)
|
27
|
-
rubocop-performance (~> 1.5.1)
|
28
|
-
rubocop-rails (~> 2.2.0)
|
29
|
-
rubocop-rspec (~> 1.37.0)
|
30
|
-
i18n (1.8.2)
|
25
|
+
i18n (1.8.11)
|
31
26
|
concurrent-ruby (~> 1.0)
|
32
27
|
jaro_winkler (1.5.4)
|
33
|
-
minitest (5.
|
28
|
+
minitest (5.15.0)
|
34
29
|
opentracing (0.5.0)
|
35
30
|
opentracing_test_tracer (0.1.1)
|
36
31
|
opentracing
|
37
32
|
parallel (1.19.1)
|
38
33
|
parser (2.7.1.1)
|
39
34
|
ast (~> 2.4.0)
|
40
|
-
rack (2.2.2)
|
41
35
|
rainbow (3.0.0)
|
42
36
|
rake (13.0.1)
|
43
37
|
rdoc (6.2.1)
|
@@ -63,22 +57,16 @@ GEM
|
|
63
57
|
rainbow (>= 2.2.2, < 4.0)
|
64
58
|
ruby-progressbar (~> 1.7)
|
65
59
|
unicode-display_width (>= 1.4.0, < 1.7)
|
66
|
-
rubocop-performance (1.5.2)
|
67
|
-
rubocop (>= 0.71.0)
|
68
|
-
rubocop-rails (2.2.1)
|
69
|
-
rack (>= 1.1)
|
70
|
-
rubocop (>= 0.72.0)
|
71
60
|
rubocop-rspec (1.37.1)
|
72
61
|
rubocop (>= 0.68.1)
|
73
62
|
ruby-progressbar (1.10.1)
|
74
63
|
sdoc (1.1.0)
|
75
64
|
rdoc (>= 5.0)
|
76
65
|
sqlite3 (1.4.2)
|
77
|
-
|
78
|
-
|
79
|
-
thread_safe (~> 0.1)
|
66
|
+
tzinfo (2.0.4)
|
67
|
+
concurrent-ruby (~> 1.0)
|
80
68
|
unicode-display_width (1.6.1)
|
81
|
-
zeitwerk (2.3
|
69
|
+
zeitwerk (2.5.3)
|
82
70
|
|
83
71
|
PLATFORMS
|
84
72
|
ruby
|
@@ -86,7 +74,6 @@ PLATFORMS
|
|
86
74
|
DEPENDENCIES
|
87
75
|
activerecord-instrumentation!
|
88
76
|
bundler (~> 1.17)
|
89
|
-
dox-style
|
90
77
|
opentracing_test_tracer (~> 0.1)
|
91
78
|
rake (~> 13.0)
|
92
79
|
rspec (~> 3.9.0)
|
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.17"
|
26
|
-
spec.add_development_dependency "dox-style"
|
27
26
|
spec.add_development_dependency "opentracing_test_tracer", "~> 0.1"
|
28
27
|
spec.add_development_dependency "rake", "~> 13.0"
|
29
28
|
spec.add_development_dependency "rspec", "~> 3.9.0"
|
@@ -8,6 +8,35 @@ module ActiveRecord
|
|
8
8
|
SPAN_KIND = "client"
|
9
9
|
DB_TYPE = "sql"
|
10
10
|
|
11
|
+
# Used to guess what type of query is running based on the first word of the query
|
12
|
+
#
|
13
|
+
# Categories are
|
14
|
+
# table: Run an action against a table changes the table metadata or configuration
|
15
|
+
# read: Read from the database
|
16
|
+
# write: Write or delete records to the database
|
17
|
+
# unknown: Can't tell the query action from the first word of the query
|
18
|
+
# not_found: First word of the query is not in this list
|
19
|
+
QUERY_CATEGORIES = {
|
20
|
+
alter: "table",
|
21
|
+
call: "unknown", # run a subquery
|
22
|
+
create: "table",
|
23
|
+
delete: "write",
|
24
|
+
drop: "table",
|
25
|
+
do: "read",
|
26
|
+
handler: "table", # table metadata
|
27
|
+
import: "write",
|
28
|
+
insert: "write",
|
29
|
+
load: "write", # covers LOAD XML and LOAD DATA queries
|
30
|
+
rename: "table",
|
31
|
+
replace: "write", # insert, on duplicate overwrite
|
32
|
+
select: "read",
|
33
|
+
table: "read", # similar to select
|
34
|
+
truncate: "table",
|
35
|
+
update: "write",
|
36
|
+
values: "unknown", # generates rows to use as a table but doesn't hit the database
|
37
|
+
with: "unknown" # sets up subqueries in preparation for other queries
|
38
|
+
}
|
39
|
+
|
11
40
|
attr_reader :tracer, :sanitizer, :sql_logging_enabled
|
12
41
|
|
13
42
|
def initialize(tracer, sanitizer: nil, sql_logging_enabled: true)
|
@@ -54,9 +83,22 @@ module ActiveRecord
|
|
54
83
|
}.merge(db_statement(payload))
|
55
84
|
end
|
56
85
|
|
86
|
+
# rubocop:disable Metrics/MethodLength
|
57
87
|
def db_statement(payload)
|
58
|
-
sql_logging_enabled
|
88
|
+
if sql_logging_enabled
|
89
|
+
query_sql = sanitize_sql(payload.fetch(:sql).squish)
|
90
|
+
first_word = query_sql.split.first.downcase
|
91
|
+
|
92
|
+
{
|
93
|
+
"db.statement" => query_sql,
|
94
|
+
"db.query_type" => first_word,
|
95
|
+
"db.query_category" => QUERY_CATEGORIES[first_word.to_sym] || "not_found"
|
96
|
+
}
|
97
|
+
else
|
98
|
+
{}
|
99
|
+
end
|
59
100
|
end
|
101
|
+
# rubocop:enable Metrics/MethodLength
|
60
102
|
|
61
103
|
def sanitize_sql(sql)
|
62
104
|
sanitizer ? sanitizer.sanitize(sql) : sql
|
@@ -76,7 +118,9 @@ module ActiveRecord
|
|
76
118
|
end
|
77
119
|
|
78
120
|
def connection_config
|
79
|
-
|
121
|
+
# Rails 6.2 will deprecate ActiveRecord::Base.connection_config
|
122
|
+
@connection_config ||=
|
123
|
+
ActiveRecord::Base.try(:connection_db_config)&.configuration_hash || ActiveRecord::Base.connection_config
|
80
124
|
end
|
81
125
|
end
|
82
126
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-instrumentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaleMove TechMovers
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -25,20 +25,6 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.17'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: dox-style
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: opentracing_test_tracer
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,11 +209,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
209
|
version: '0'
|
224
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
211
|
requirements:
|
226
|
-
- - "
|
212
|
+
- - ">"
|
227
213
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
214
|
+
version: 1.3.1
|
229
215
|
requirements: []
|
230
|
-
rubygems_version: 3.1.
|
216
|
+
rubygems_version: 3.1.6
|
231
217
|
signing_key:
|
232
218
|
specification_version: 4
|
233
219
|
summary: ActiveRecord OpenTracing intrumenter
|