traxor 0.1.20 → 0.2.0

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: dea761fab3589a04486586d79af18c4b8842bd244604e8d615991e5448440c3f
4
- data.tar.gz: 776766f8e25224a68067ab89474fd6e65be172ad116f1f6dae5138b5de7363d6
3
+ metadata.gz: a473abfe8f2c81c9eb1e13e44c41059ede049b24070c5cf3beac9f3c0b68bbcb
4
+ data.tar.gz: 00e1a58008e868bb376b57206f184b02d0189e13600fd251e0c9dbcc2f3c9cea
5
5
  SHA512:
6
- metadata.gz: 7312eacdd60f37e8c1b901ba96f172e7846695af03168f35811d0615c2eacf6cb162465065b8f43e4f6d0d3c7cb696ba4de094ce515af21fa280ecc16ef8ee4f
7
- data.tar.gz: 98d4259851f7126615e7dacdb6c2273234a9171d5260745edaddbac06a46fb42b1696e17cf820e8836d5ca3d3aabfdfa6fe4dbc2e0f954ab37f9890bfa128a8a
6
+ metadata.gz: 6d1a62f7e1c1f9d3f47689ce54ff65a124f8e8bf77dfe0d59423e152f686ae400ddb6d900a3eb56bae628778c4620bbc1a685d698b93c6ee4366fedb1cb9b97c
7
+ data.tar.gz: bdefe79058a721b7d9eb7bc1347074c44b3abe99a4b35f0ba5432ad6ac892d2d0b4e78e111d59a288d34acc2eb9c4ceb9845e57463dc87e5d9aaa8e74f9f2d4a
@@ -11,6 +11,18 @@ Style/Documentation:
11
11
  Metrics/LineLength:
12
12
  Max: 100
13
13
 
14
+ Metrics/AbcSize:
15
+ Max: 30
16
+
17
+ Metrics/MethodLength:
18
+ Max: 15
19
+
20
+ Metrics/PerceivedComplexity:
21
+ Max: 15
22
+
23
+ Metrics/CyclomaticComplexity:
24
+ Max: 15
25
+
14
26
  Metrics/BlockLength:
15
27
  Exclude:
16
28
  - '**/spec/**/*'
@@ -1,49 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- traxor (0.1.20)
4
+ traxor (0.2.0)
5
5
  activesupport (>= 5.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.2.1)
11
- actionpack (= 5.2.1)
10
+ actioncable (5.2.2)
11
+ actionpack (= 5.2.2)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailer (5.2.1)
15
- actionpack (= 5.2.1)
16
- actionview (= 5.2.1)
17
- activejob (= 5.2.1)
14
+ actionmailer (5.2.2)
15
+ actionpack (= 5.2.2)
16
+ actionview (= 5.2.2)
17
+ activejob (= 5.2.2)
18
18
  mail (~> 2.5, >= 2.5.4)
19
19
  rails-dom-testing (~> 2.0)
20
- actionpack (5.2.1)
21
- actionview (= 5.2.1)
22
- activesupport (= 5.2.1)
20
+ actionpack (5.2.2)
21
+ actionview (= 5.2.2)
22
+ activesupport (= 5.2.2)
23
23
  rack (~> 2.0)
24
24
  rack-test (>= 0.6.3)
25
25
  rails-dom-testing (~> 2.0)
26
26
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.2.1)
28
- activesupport (= 5.2.1)
27
+ actionview (5.2.2)
28
+ activesupport (= 5.2.2)
29
29
  builder (~> 3.1)
30
30
  erubi (~> 1.4)
31
31
  rails-dom-testing (~> 2.0)
32
32
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.2.1)
34
- activesupport (= 5.2.1)
33
+ activejob (5.2.2)
34
+ activesupport (= 5.2.2)
35
35
  globalid (>= 0.3.6)
36
- activemodel (5.2.1)
37
- activesupport (= 5.2.1)
38
- activerecord (5.2.1)
39
- activemodel (= 5.2.1)
40
- activesupport (= 5.2.1)
36
+ activemodel (5.2.2)
37
+ activesupport (= 5.2.2)
38
+ activerecord (5.2.2)
39
+ activemodel (= 5.2.2)
40
+ activesupport (= 5.2.2)
41
41
  arel (>= 9.0)
42
- activestorage (5.2.1)
43
- actionpack (= 5.2.1)
44
- activerecord (= 5.2.1)
42
+ activestorage (5.2.2)
43
+ actionpack (= 5.2.2)
44
+ activerecord (= 5.2.2)
45
45
  marcel (~> 0.3.1)
46
- activesupport (5.2.1)
46
+ activesupport (5.2.2)
47
47
  concurrent-ruby (~> 1.0, >= 1.0.2)
48
48
  i18n (>= 0.7, < 2)
49
49
  minitest (~> 5.1)
@@ -65,7 +65,7 @@ GEM
65
65
  coderay (1.1.2)
66
66
  coercible (1.0.0)
67
67
  descendants_tracker (~> 0.0.1)
68
- concurrent-ruby (1.0.5)
68
+ concurrent-ruby (1.1.4)
69
69
  connection_pool (2.2.2)
70
70
  crass (1.0.4)
71
71
  descendants_tracker (0.0.4)
@@ -73,14 +73,14 @@ GEM
73
73
  diff-lcs (1.3)
74
74
  docile (1.3.1)
75
75
  equalizer (0.0.11)
76
- erubi (1.7.1)
77
- faraday (0.15.2)
76
+ erubi (1.8.0)
77
+ faraday (0.15.4)
78
78
  multipart-post (>= 1.2, < 3)
79
- ffi (1.9.25)
79
+ ffi (1.10.0)
80
80
  formatador (0.2.5)
81
81
  globalid (0.4.1)
82
82
  activesupport (>= 4.2.0)
83
- guard (2.14.2)
83
+ guard (2.15.0)
84
84
  formatador (>= 0.2.4)
85
85
  listen (>= 2.7, < 4.0)
86
86
  lumberjack (>= 1.0.12, < 2.0)
@@ -94,86 +94,88 @@ GEM
94
94
  guard (~> 2.1)
95
95
  guard-compat (~> 1.1)
96
96
  rspec (>= 2.99.0, < 4.0)
97
- i18n (1.1.0)
97
+ i18n (1.5.1)
98
98
  concurrent-ruby (~> 1.0)
99
99
  ice_nine (0.11.2)
100
- jaro_winkler (1.5.1)
100
+ jaro_winkler (1.5.2)
101
101
  json (2.1.0)
102
102
  kwalify (0.7.2)
103
103
  listen (3.1.5)
104
104
  rb-fsevent (~> 0.9, >= 0.9.4)
105
105
  rb-inotify (~> 0.9, >= 0.9.7)
106
106
  ruby_dep (~> 1.2)
107
- loofah (2.2.2)
107
+ loofah (2.2.3)
108
108
  crass (~> 1.0.2)
109
109
  nokogiri (>= 1.5.9)
110
110
  lumberjack (1.0.13)
111
- mail (2.7.0)
111
+ mail (2.7.1)
112
112
  mini_mime (>= 0.1.1)
113
- marcel (0.3.2)
113
+ marcel (0.3.3)
114
114
  mimemagic (~> 0.3.2)
115
- method_source (0.9.0)
116
- mimemagic (0.3.2)
115
+ method_source (0.9.2)
116
+ mimemagic (0.3.3)
117
117
  mini_mime (1.0.1)
118
- mini_portile2 (2.3.0)
118
+ mini_portile2 (2.4.0)
119
119
  minitest (5.11.3)
120
120
  multipart-post (2.0.0)
121
121
  nenv (0.3.0)
122
122
  nio4r (2.3.1)
123
- nokogiri (1.8.4)
124
- mini_portile2 (~> 2.3.0)
123
+ nokogiri (1.10.0)
124
+ mini_portile2 (~> 2.4.0)
125
125
  notiffany (0.1.1)
126
126
  nenv (~> 0.1)
127
127
  shellany (~> 0.0)
128
128
  parallel (1.12.1)
129
- parser (2.5.1.2)
129
+ parser (2.5.3.0)
130
130
  ast (~> 2.4.0)
131
131
  powerpack (0.1.2)
132
- pry (0.11.3)
132
+ pry (0.12.2)
133
133
  coderay (~> 1.1.0)
134
134
  method_source (~> 0.9.0)
135
135
  pry-byebug (3.6.0)
136
136
  byebug (~> 10.0)
137
137
  pry (~> 0.10)
138
- rack (2.0.5)
139
- rack-protection (2.0.3)
138
+ psych (3.1.0)
139
+ rack (2.0.6)
140
+ rack-protection (2.0.5)
140
141
  rack
141
142
  rack-test (1.1.0)
142
143
  rack (>= 1.0, < 3)
143
- rails (5.2.1)
144
- actioncable (= 5.2.1)
145
- actionmailer (= 5.2.1)
146
- actionpack (= 5.2.1)
147
- actionview (= 5.2.1)
148
- activejob (= 5.2.1)
149
- activemodel (= 5.2.1)
150
- activerecord (= 5.2.1)
151
- activestorage (= 5.2.1)
152
- activesupport (= 5.2.1)
144
+ rails (5.2.2)
145
+ actioncable (= 5.2.2)
146
+ actionmailer (= 5.2.2)
147
+ actionpack (= 5.2.2)
148
+ actionview (= 5.2.2)
149
+ activejob (= 5.2.2)
150
+ activemodel (= 5.2.2)
151
+ activerecord (= 5.2.2)
152
+ activestorage (= 5.2.2)
153
+ activesupport (= 5.2.2)
153
154
  bundler (>= 1.3.0)
154
- railties (= 5.2.1)
155
+ railties (= 5.2.2)
155
156
  sprockets-rails (>= 2.0.0)
156
157
  rails-dom-testing (2.0.3)
157
158
  activesupport (>= 4.2.0)
158
159
  nokogiri (>= 1.6)
159
160
  rails-html-sanitizer (1.0.4)
160
161
  loofah (~> 2.2, >= 2.2.2)
161
- railties (5.2.1)
162
- actionpack (= 5.2.1)
163
- activesupport (= 5.2.1)
162
+ railties (5.2.2)
163
+ actionpack (= 5.2.2)
164
+ activesupport (= 5.2.2)
164
165
  method_source
165
166
  rake (>= 0.8.7)
166
167
  thor (>= 0.19.0, < 2.0)
167
168
  rainbow (3.0.0)
168
- rake (12.3.1)
169
+ rake (12.3.2)
169
170
  rb-fsevent (0.10.3)
170
- rb-inotify (0.9.10)
171
- ffi (>= 0.5.0, < 2)
172
- redis (4.0.2)
173
- reek (5.0.2)
171
+ rb-inotify (0.10.0)
172
+ ffi (~> 1.0)
173
+ redis (4.1.0)
174
+ reek (5.3.0)
174
175
  codeclimate-engine-rb (~> 0.4.0)
175
176
  kwalify (~> 0.7.0)
176
177
  parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
178
+ psych (~> 3.1.0)
177
179
  rainbow (>= 2.0, < 4.0)
178
180
  rspec (3.8.0)
179
181
  rspec-core (~> 3.8.0)
@@ -181,7 +183,7 @@ GEM
181
183
  rspec-mocks (~> 3.8.0)
182
184
  rspec-core (3.8.0)
183
185
  rspec-support (~> 3.8.0)
184
- rspec-expectations (3.8.1)
186
+ rspec-expectations (3.8.2)
185
187
  diff-lcs (>= 1.2.0, < 2.0)
186
188
  rspec-support (~> 3.8.0)
187
189
  rspec-mocks (3.8.0)
@@ -190,19 +192,20 @@ GEM
190
192
  rspec-support (3.8.0)
191
193
  rspec_junit_formatter (0.4.1)
192
194
  rspec-core (>= 2, < 4, != 2.12.0)
193
- rubocop (0.58.2)
195
+ rubocop (0.62.0)
194
196
  jaro_winkler (~> 1.5.1)
195
197
  parallel (~> 1.10)
196
198
  parser (>= 2.5, != 2.5.1.1)
197
199
  powerpack (~> 0.1)
198
200
  rainbow (>= 2.2.2, < 4.0)
199
201
  ruby-progressbar (~> 1.7)
200
- unicode-display_width (~> 1.0, >= 1.0.1)
202
+ unicode-display_width (~> 1.4.0)
201
203
  ruby-progressbar (1.10.0)
202
204
  ruby_dep (1.5.0)
203
205
  shellany (0.0.1)
204
- sidekiq (5.2.1)
206
+ sidekiq (5.2.5)
205
207
  connection_pool (~> 2.2, >= 2.2.2)
208
+ rack (>= 1.5.0)
206
209
  rack-protection (>= 1.5.0)
207
210
  redis (>= 3.3.5, < 5)
208
211
  simplecov (0.16.1)
@@ -217,11 +220,11 @@ GEM
217
220
  actionpack (>= 4.0)
218
221
  activesupport (>= 4.0)
219
222
  sprockets (>= 3.0.0)
220
- thor (0.20.0)
223
+ thor (0.20.3)
221
224
  thread_safe (0.3.6)
222
225
  tzinfo (1.2.5)
223
226
  thread_safe (~> 0.1)
224
- unicode-display_width (1.4.0)
227
+ unicode-display_width (1.4.1)
225
228
  virtus (1.0.5)
226
229
  axiom-types (~> 0.1)
227
230
  coercible (~> 1.0)
@@ -249,6 +252,3 @@ DEPENDENCIES
249
252
  sidekiq
250
253
  simplecov
251
254
  traxor!
252
-
253
- BUNDLED WITH
254
- 1.16.4
@@ -19,7 +19,7 @@ module Traxor
19
19
  end
20
20
 
21
21
  def self.enabled?
22
- @enabled ||= ENV.fetch('TRAXOR_ENABLED', true).present?
22
+ ENV['DISABLE_TRAXOR'].blank?
23
23
  end
24
24
 
25
25
  def self.scopes
@@ -28,6 +28,8 @@ module Traxor
28
28
  .to_s
29
29
  .downcase
30
30
  .split(',')
31
+ .map(&:strip)
32
+ .map(&:chomp)
31
33
  .map(&:to_sym)
32
34
  end
33
35
  end
@@ -12,8 +12,10 @@ module Traxor
12
12
  duration = (event.duration || 0.0).to_f
13
13
  tags = { faraday_host: url.host, faraday_method: event.payload[:method] }
14
14
 
15
- Metric.count COUNT_METRIC, 1, tags
16
- Metric.measure DURATION_METRIC, "#{duration.round(2)}ms", tags if duration.positive?
15
+ Metric::Line.record do |l|
16
+ l.count COUNT_METRIC, 1, tags
17
+ l.measure DURATION_METRIC, "#{duration.round(2)}ms", tags if duration.positive?
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -1,39 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/string/inflections'
3
+ require 'traxor/metric/line'
4
4
 
5
5
  module Traxor
6
6
  module Metric
7
7
  def self.count(name, value, tags = {})
8
- log("count##{name}=#{value} #{tag_string(tags)}")
8
+ Line.record { |l| l.count(name, value, tags) }
9
9
  end
10
10
 
11
11
  def self.measure(name, value, tags = {})
12
- log("measure##{name}=#{value} #{tag_string(tags)}")
12
+ Line.record { |l| l.measure(name, value, tags) }
13
13
  end
14
14
 
15
15
  def self.sample(name, value, tags = {})
16
- log("sample##{name}=#{value} #{tag_string(tags)}")
17
- end
18
-
19
- def self.tag_string(tags)
20
- Hash(tags).merge(Traxor::Tags.all).map do |tag_name, tag_value|
21
- "tag##{tag_name}=#{tag_value}"
22
- end.join(' ')
23
- end
24
-
25
- def self.normalize_values(value)
26
- value.to_s.gsub(/::/, '.').underscore.strip
27
- end
28
-
29
- def self.log(string)
30
- return unless Traxor.enabled?
31
-
32
- logger.info(normalize_values(string))
33
- end
34
-
35
- def self.logger
36
- Traxor.logger
16
+ Line.record { |l| l.sample(name, value, tags) }
37
17
  end
38
18
  end
39
19
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+
5
+ module Traxor
6
+ module Metric
7
+ class Line
8
+ def self.record
9
+ line = new
10
+ yield line
11
+ line.flush
12
+ end
13
+
14
+ def initialize
15
+ @counts = []
16
+ @measures = []
17
+ @samples = []
18
+ @tags = {}
19
+ end
20
+
21
+ def count(name, value, tags = {})
22
+ @counts << [name, value]
23
+ @tags.merge!(tags)
24
+ end
25
+
26
+ def measure(name, value, tags = {})
27
+ @measures << [name, value]
28
+ @tags.merge!(tags)
29
+ end
30
+
31
+ def sample(name, value, tags = {})
32
+ @samples << [name, value]
33
+ @tags.merge!(tags)
34
+ end
35
+
36
+ def flush
37
+ line = ''
38
+
39
+ @counts.each { |name, value| line += " count##{name}=#{value}" }
40
+ @measures.each { |name, value| line += " measure##{name}=#{value}" }
41
+ @samples.each { |name, value| line += " sample##{name}=#{value}" }
42
+
43
+ log("#{line} #{tag_string(@tags)}")
44
+ end
45
+
46
+ def tag_string(tags)
47
+ Hash(tags).merge(Traxor::Tags.all).map do |tag_name, tag_value|
48
+ "tag##{tag_name}=#{tag_value}"
49
+ end.join(' ')
50
+ end
51
+
52
+ def normalize_values(value)
53
+ value.to_s.gsub(/::/, '.').underscore.strip
54
+ end
55
+
56
+ def log(string)
57
+ return unless Traxor.enabled?
58
+
59
+ logger.info(normalize_values(string))
60
+ end
61
+
62
+ def logger
63
+ Traxor.logger
64
+ end
65
+ end
66
+ end
67
+ end
@@ -30,34 +30,38 @@ module Traxor
30
30
  Middleware.gc_stat_after = GC.stat
31
31
  Middleware.post_finish_at = Time.now.utc
32
32
 
33
- record_request_metrics
34
- record_gc_metrics
33
+ record_metrics
35
34
 
36
35
  [status, headers, body]
37
36
  end
38
37
 
39
- def record_request_metrics
38
+ def record_metrics
39
+ Metric::Line.record do |l|
40
+ record_request_metrics(l)
41
+ record_gc_metrics(l)
42
+ end
43
+ end
44
+
45
+ def record_request_metrics(line)
40
46
  if Middleware.middleware_total.positive?
41
- Metric.measure MIDDLEWARE_METRIC, "#{Middleware.middleware_total.round(2)}ms"
47
+ line.measure MIDDLEWARE_METRIC, "#{Middleware.middleware_total.round(2)}ms"
42
48
  end
43
49
  if Middleware.request_total.positive?
44
- Metric.measure DURATION_METRIC, "#{Middleware.request_total.round(2)}ms"
50
+ line.measure DURATION_METRIC, "#{Middleware.request_total.round(2)}ms"
45
51
  end
46
52
  if Middleware.request_queue_total.positive?
47
- Metric.measure QUEUE_METRIC, "#{Middleware.request_queue_total.round(2)}ms"
53
+ line.measure QUEUE_METRIC, "#{Middleware.request_queue_total.round(2)}ms"
48
54
  end
49
- Metric.count REQUEST_COUNT_METRIC, 1
55
+ line.count REQUEST_COUNT_METRIC, 1
50
56
  end
51
57
 
52
- def record_gc_metrics
58
+ def record_gc_metrics(line)
53
59
  total_gc_time = (GC::Profiler.total_time * 1_000).to_f
54
- if total_gc_time.positive?
55
- Metric.measure GC_DURATION_METRIC, "#{total_gc_time.round(2)}ms"
56
- end
57
- Metric.count GC_COUNT_METRIC, Middleware.gc_count
58
- Metric.count MAJOR_METRIC, Middleware.gc_major_count
59
- Metric.count MINOR_METRIC, Middleware.gc_minor_count
60
- Metric.count ALLOCATED_METRIC, Middleware.gc_allocated_objects_count
60
+ line.measure GC_DURATION_METRIC, "#{total_gc_time.round(2)}ms" if total_gc_time.positive?
61
+ line.count GC_COUNT_METRIC, Middleware.gc_count
62
+ line.count MAJOR_METRIC, Middleware.gc_major_count
63
+ line.count MINOR_METRIC, Middleware.gc_minor_count
64
+ line.count ALLOCATED_METRIC, Middleware.gc_allocated_objects_count
61
65
 
62
66
  GC::Profiler.clear
63
67
  end
@@ -12,7 +12,7 @@ module Traxor
12
12
  VIEW_METRIC = 'rails.action_controller.view.duration'
13
13
  EXCEPTION_METRIC = 'rails.action_controller.exception.count'
14
14
 
15
- def self.set_controller_tags(event)
15
+ def self.add_controller_tags(event)
16
16
  Traxor::Tags.controller = {
17
17
  controller_name: event.payload[:controller],
18
18
  controller_action: event.payload[:action],
@@ -27,12 +27,14 @@ module Traxor
27
27
  view_runtime = (event.payload[:view_runtime] || 0.0).to_f
28
28
  ruby_runtime = duration - db_runtime - view_runtime
29
29
 
30
- Metric.count COUNT_METRIC, 1
31
- Metric.measure TOTAL_METRIC, "#{duration.round(2)}ms" if duration.positive?
32
- Metric.measure RUBY_METRIC, "#{ruby_runtime.round(2)}ms" if ruby_runtime.positive?
33
- Metric.measure DB_METRIC, "#{db_runtime.round(2)}ms" if db_runtime.positive?
34
- Metric.measure VIEW_METRIC, "#{view_runtime.round(2)}ms" if view_runtime.positive?
35
- Metric.count EXCEPTION_METRIC, 1 if exception
30
+ Metric::Line.record do |l|
31
+ l.count COUNT_METRIC, 1
32
+ l.measure TOTAL_METRIC, "#{duration.round(2)}ms" if duration.positive?
33
+ l.measure RUBY_METRIC, "#{ruby_runtime.round(2)}ms" if ruby_runtime.positive?
34
+ l.measure DB_METRIC, "#{db_runtime.round(2)}ms" if db_runtime.positive?
35
+ l.measure VIEW_METRIC, "#{view_runtime.round(2)}ms" if view_runtime.positive?
36
+ l.count EXCEPTION_METRIC, 1 if exception
37
+ end
36
38
  end
37
39
  end
38
40
  end
@@ -41,7 +43,7 @@ end
41
43
  if Traxor.enabled? && Traxor.scopes.include?(:action_controller)
42
44
  ActiveSupport::Notifications.subscribe 'start_processing.action_controller' do |*args|
43
45
  event = ActiveSupport::Notifications::Event.new(*args)
44
- Traxor::Rails::ActionController.set_controller_tags(event)
46
+ Traxor::Rails::ActionController.add_controller_tags(event)
45
47
  end
46
48
 
47
49
  ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |*args|
@@ -16,14 +16,17 @@ module Traxor
16
16
  sql = event.payload[:sql].to_s.strip.upcase
17
17
  name = event.payload[:name].to_s.strip
18
18
  return if name.casecmp('SCHEMA').zero?
19
+
19
20
  tags = {}
20
21
  tags[:active_record_class_name] = name.split.first if name.length.positive?
21
22
 
22
- Metric.count COUNT_METRIC, 1, tags
23
- Metric.count SELECT_METRIC, 1, tags if sql.start_with?('SELECT')
24
- Metric.count INSERT_METRIC, 1, tags if sql.start_with?('INSERT')
25
- Metric.count UPDATE_METRIC, 1, tags if sql.start_with?('UPDATE')
26
- Metric.count DELETE_METRIC, 1, tags if sql.start_with?('DELETE')
23
+ Metric::Line.record do |l|
24
+ l.count COUNT_METRIC, 1, tags
25
+ l.count SELECT_METRIC, 1, tags if sql.start_with?('SELECT')
26
+ l.count INSERT_METRIC, 1, tags if sql.start_with?('INSERT')
27
+ l.count UPDATE_METRIC, 1, tags if sql.start_with?('UPDATE')
28
+ l.count DELETE_METRIC, 1, tags if sql.start_with?('DELETE')
29
+ end
27
30
  end
28
31
 
29
32
  def self.record_instantiations(event)
@@ -10,9 +10,11 @@ module Traxor
10
10
 
11
11
  def call(worker, _job, queue)
12
12
  tags = Traxor::Tags.sidekiq = { sidekiq_worker: worker.class.name, sidekiq_queue: queue }
13
- Metric.count COUNT_METRIC, 1, tags
14
- time = Benchmark.ms { yield }
15
- Metric.measure DURATION_METRIC, "#{time.round(2)}ms", tags if time.positive?
13
+ Metric::Line.record do |l|
14
+ l.count COUNT_METRIC, 1, tags
15
+ time = Benchmark.ms { yield }
16
+ l.measure DURATION_METRIC, "#{time.round(2)}ms", tags if time.positive?
17
+ end
16
18
  end
17
19
  end
18
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Traxor
4
- VERSION = '0.1.20'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traxor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Hansen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-07 00:00:00.000000000 Z
11
+ date: 2019-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -245,6 +245,7 @@ files:
245
245
  - lib/traxor.rb
246
246
  - lib/traxor/faraday.rb
247
247
  - lib/traxor/metric.rb
248
+ - lib/traxor/metric/line.rb
248
249
  - lib/traxor/rack.rb
249
250
  - lib/traxor/rack/middleware.rb
250
251
  - lib/traxor/rack/middleware/post.rb
@@ -279,8 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
280
  - !ruby/object:Gem::Version
280
281
  version: '0'
281
282
  requirements: []
282
- rubyforge_project:
283
- rubygems_version: 2.7.7
283
+ rubygems_version: 3.0.3
284
284
  signing_key:
285
285
  specification_version: 4
286
286
  summary: Log metrics to akkeris platform