scout_apm 3.0.0.pre26 → 3.0.0.pre27

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
  SHA1:
3
- metadata.gz: d464aa5c996bd02a57ce41e4fe6891ea7cac1c27
4
- data.tar.gz: ac8778e12b752200d391e0dd8a5e9e56e19ac5e7
3
+ metadata.gz: 83c69774d0c470897fe065d9ad4c72140b0ed48d
4
+ data.tar.gz: cf58a5b2f366ee3df3c7ecba9a453010684e00ef
5
5
  SHA512:
6
- metadata.gz: a3554af6cc62a696af7fcfc31b027bd54294f80159b19cc5727fd2946c00cc53d04e1cdaf82c72bf956e011bb21f7ccc3da31a7a510aa021ef7fda74ec9d0667
7
- data.tar.gz: 421dbf05b82468f80a40e4b7fa95d45e890bc1a68e401476603c54728b3f50f9282d304bf57044a60c0750d1fc51b0ae0ccc4d2fc60f6ccdfcebe77068b95711
6
+ metadata.gz: 81b2c54c39a670f3a058c8493bee77a5ac0071bda90860bfabe1d4b7814d5ce0556354a800116ece34343739d6d6f0185d60958c7aaacf79731550861e9edb97
7
+ data.tar.gz: bc17ad078833fe7aacf9f461b6f3f0eee0a911e1cd3fe7d354dd5694e6cba70c81c24b312482f3f011f30ae261141bf6503b0810acb9a1206c7cf84a01bec53c
@@ -2,6 +2,15 @@
2
2
 
3
3
  * ScoutProf BETA
4
4
 
5
+ # 2.4.17
6
+
7
+ * Renames SQL `BEGIN` and `COMMIT` statements from `SQL#other` to `SQL#begin` and `SQL#commit`, respectively.
8
+ * Makes naming between transaction and database metrics consistent. Previously, database metrics lacking a provided ActiveRecord label were named `SQL#other`.
9
+
10
+ # 2.4.16
11
+
12
+ * Fix synchronization bug in Store (#205, PR #210)
13
+
5
14
  # 2.4.15
6
15
 
7
16
  * Fix bug that causes no data to be reported to Scout when DataDog is installed (#211)
@@ -6,6 +6,7 @@ end
6
6
  #####################################
7
7
  require 'cgi'
8
8
  require 'logger'
9
+ require 'monitor'
9
10
  require 'net/http'
10
11
  require 'openssl'
11
12
  require 'pp'
@@ -13,7 +13,6 @@ module ScoutApm
13
13
 
14
14
  walker.on do |layer|
15
15
  next if skip_layer?(layer)
16
-
17
16
  stat = DbQueryMetricStats.new(
18
17
  model_name(layer),
19
18
  operation_name(layer),
@@ -52,23 +51,11 @@ module ScoutApm
52
51
  DEFAULT_OPERATION = "other"
53
52
 
54
53
  def model_name(layer)
55
- if layer.name.respond_to?(:model)
56
- layer.name.model || DEFAULT_MODEL
57
- else
58
- DEFAULT_MODEL
59
- end
60
- rescue
61
- DEFAULT_MODEL
54
+ layer.name.to_s.split("/").first || DEFAULT_MODEL
62
55
  end
63
56
 
64
57
  def operation_name(layer)
65
- if layer.name.respond_to?(:normalized_operation)
66
- layer.name.normalized_operation || DEFAULT_OPERATION
67
- else
68
- DEFAULT_OPERATION
69
- end
70
- rescue
71
- DEFAULT_OPERATION
58
+ layer.name.to_s.split("/")[1] || DEFAULT_OPERATION
72
59
  end
73
60
 
74
61
  def records_returned(layer)
@@ -5,8 +5,10 @@ module ScoutApm
5
5
  class Store
6
6
  def initialize(context)
7
7
  @context = context
8
- @mutex = Mutex.new
9
- @reporting_periods = Hash.new { |h,k| h[k] = StoreReportingPeriod.new(k, @context) }
8
+ @mutex = Monitor.new
9
+ @reporting_periods = Hash.new { |h,k|
10
+ @mutex.synchronize { h[k] = StoreReportingPeriod.new(k, @context) }
11
+ }
10
12
  @samplers = []
11
13
  end
12
14
 
@@ -87,8 +89,13 @@ module ScoutApm
87
89
  def write_to_layaway(layaway, force=false)
88
90
  logger.debug("Writing to layaway#{" (Forced)" if force}")
89
91
 
90
- @reporting_periods.select { |time, rp| force || (time.timestamp < current_timestamp.timestamp) }.
91
- each { |time, rp| write_reporting_period(layaway, time, rp) }
92
+ to_report = @mutex.synchronize {
93
+ @reporting_periods.select { |time, rp|
94
+ force || (time.timestamp < current_timestamp.timestamp)
95
+ }
96
+ }
97
+
98
+ to_report.each { |time, rp| write_reporting_period(layaway, time, rp) }
92
99
  end
93
100
 
94
101
  # For each tick (minute), be sure we have a reporting period, and that samplers are run for it.
@@ -98,14 +105,12 @@ module ScoutApm
98
105
  end
99
106
 
100
107
  def write_reporting_period(layaway, time, rp)
101
- @mutex.synchronize {
102
108
  layaway.write_reporting_period(rp)
103
- }
104
109
  rescue => e
105
110
  logger.warn("Failed writing data to layaway file: #{e.message} / #{e.backtrace}")
106
111
  ensure
107
112
  logger.debug("Before delete, reporting periods length: #{@reporting_periods.size}")
108
- deleted_items = @reporting_periods.delete(time)
113
+ deleted_items = @mutex.synchronize { @reporting_periods.delete(time) }
109
114
  logger.debug("After delete, reporting periods length: #{@reporting_periods.size}. Did delete #{deleted_items}")
110
115
  end
111
116
  private :write_reporting_period
@@ -12,22 +12,27 @@ module ScoutApm
12
12
  # Converts an SQL string and the name (typically assigned automatically
13
13
  # by rails) into a Scout metric_name.
14
14
  #
15
+ # This prefers to use the ActiveRecord-provided name over parsing SQL as parsing is slower.
16
+ #
15
17
  # sql: SELECT "places".* FROM "places" ORDER BY "places"."position" ASC
16
18
  # name: Place Load
17
19
  # metric_name: Place/find
18
20
  def to_s
21
+ return @to_s if @to_s
19
22
  parsed = parse_operation
20
23
  if parsed
21
- "#{model}/#{parsed}"
24
+ @to_s = "#{model}/#{parsed}"
22
25
  else
23
- regex_name(sql)
26
+ @to_s = regex_name(sql)
24
27
  end
25
28
  end
26
29
 
30
+ # This only returns a value if a name is provided via +initialize+.
27
31
  def model
28
32
  parts.first
29
33
  end
30
34
 
35
+ # This only returns a value if a name is provided via +initialize+.
31
36
  def normalized_operation
32
37
  parse_operation
33
38
  end
@@ -49,12 +54,14 @@ module ScoutApm
49
54
 
50
55
  private
51
56
 
57
+ # This only returns a value if a name is provided via +initialize+.
52
58
  def operation
53
59
  if parts.length >= 2
54
60
  parts[1].downcase
55
61
  end
56
62
  end
57
63
 
64
+ # This only returns a value if a name is provided via +initialize+.
58
65
  def parts
59
66
  name.split(" ")
60
67
  end
@@ -86,6 +93,8 @@ module ScoutApm
86
93
  NON_GREEDY_CONSUME = '.*?'
87
94
  TABLE = '(?:"|`)?(.*?)(?:"|`)?\s'
88
95
  COUNT = 'COUNT\(.*?\)'
96
+ BEGIN_STATEMENT = 'BEGIN'.freeze # BEGIN is a reserved keyword
97
+ COMMIT = 'COMMIT'.freeze
89
98
 
90
99
  SELECT_REGEX = /\A#{WHITE_SPACE}(SELECT)#{WHITE_SPACE}(#{COUNT})?#{NON_GREEDY_CONSUME}#{FROM}#{WHITE_SPACE}#{TABLE}/i.freeze
91
100
  UPDATE_REGEX = /\A#{WHITE_SPACE}(UPDATE)#{WHITE_SPACE}#{TABLE}/i.freeze
@@ -121,13 +130,17 @@ module ScoutApm
121
130
  else
122
131
  SELECT_LABEL
123
132
  end
124
- "#{match[3].classify}/#{operation}"
133
+ "#{match[3].gsub(/\W/,'').classify}/#{operation}"
125
134
  elsif match = UPDATE_REGEX.match(sql)
126
135
  "#{match[2].classify}/#{UPDATE_LABEL}"
127
136
  elsif match = INSERT_REGEX.match(sql)
128
137
  "#{match[2].classify}/#{INSERT_LABEL}"
129
138
  elsif match = DELETE_REGEX.match(sql)
130
139
  "#{match[2].classify}/#{DELETE_LABEL}"
140
+ elsif sql == BEGIN_STATEMENT
141
+ "SQL/#{BEGIN_STATEMENT.downcase}"
142
+ elsif sql == COMMIT
143
+ "SQL/#{COMMIT.downcase}"
131
144
  else
132
145
  UNKNOWN_LABEL
133
146
  end
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "3.0.0.pre26"
2
+ VERSION = "3.0.0.pre27"
3
3
  end
@@ -64,6 +64,16 @@ class ActiveRecordMetricNameTest < Minitest::Test
64
64
  assert_equal "User/find", mn.to_s
65
65
  end
66
66
 
67
+ def test_begin_statement
68
+ mn = ScoutApm::Utils::ActiveRecordMetricName.new("BEGIN", nil)
69
+ assert_equal "SQL/begin", mn.to_s
70
+ end
71
+
72
+ def test_commit
73
+ mn = ScoutApm::Utils::ActiveRecordMetricName.new("COMMIT", nil)
74
+ assert_equal "SQL/commit", mn.to_s
75
+ end
76
+
67
77
 
68
78
  # Regex test cases, pass these in w/ "SQL" as the AR provided name field
69
79
  [
@@ -89,8 +99,6 @@ class ActiveRecordMetricNameTest < Minitest::Test
89
99
  # Stuff we don't care about in SQL
90
100
  ["SQL/other", 'SET SESSION statement_timeout = ?'],
91
101
  ["SQL/other", 'SHOW TIME ZONE'],
92
- ["SQL/other", 'BEGIN'],
93
- ["SQL/other", 'COMMIT'],
94
102
 
95
103
  # Empty strings, or invalid SQL
96
104
  ["SQL/other", ''],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre26
4
+ version: 3.0.0.pre27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Haynes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-07 00:00:00.000000000 Z
12
+ date: 2018-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -397,8 +397,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
397
397
  version: 1.3.1
398
398
  requirements: []
399
399
  rubyforge_project: scout_apm
400
- rubygems_version: 2.4.5.5
400
+ rubygems_version: 2.4.6
401
401
  signing_key:
402
402
  specification_version: 4
403
403
  summary: Ruby application performance monitoring
404
- test_files: []
404
+ test_files:
405
+ - test/data/config_test_1.yml
406
+ - test/test_helper.rb
407
+ - test/unit/agent_test.rb
408
+ - test/unit/background_job_integrations/sidekiq_test.rb
409
+ - test/unit/config_test.rb
410
+ - test/unit/context_test.rb
411
+ - test/unit/db_query_metric_set_test.rb
412
+ - test/unit/db_query_metric_stats_test.rb
413
+ - test/unit/environment_test.rb
414
+ - test/unit/extensions/periodic_callbacks_test.rb
415
+ - test/unit/extensions/transaction_callbacks_test.rb
416
+ - test/unit/fake_store_test.rb
417
+ - test/unit/git_revision_test.rb
418
+ - test/unit/histogram_test.rb
419
+ - test/unit/ignored_uris_test.rb
420
+ - test/unit/instruments/active_record_instruments_test.rb
421
+ - test/unit/instruments/net_http_test.rb
422
+ - test/unit/instruments/percentile_sampler_test.rb
423
+ - test/unit/layaway_test.rb
424
+ - test/unit/layer_children_set_test.rb
425
+ - test/unit/layer_converters/depth_first_walker_test.rb
426
+ - test/unit/layer_converters/metric_converter_test.rb
427
+ - test/unit/layer_converters/stubs.rb
428
+ - test/unit/limited_layer_test.rb
429
+ - test/unit/logger_test.rb
430
+ - test/unit/metric_set_test.rb
431
+ - test/unit/remote/test_message.rb
432
+ - test/unit/remote/test_router.rb
433
+ - test/unit/remote/test_server.rb
434
+ - test/unit/scored_item_set_test.rb
435
+ - test/unit/serializers/payload_serializer_test.rb
436
+ - test/unit/slow_job_policy_test.rb
437
+ - test/unit/slow_request_policy_test.rb
438
+ - test/unit/sql_sanitizer_test.rb
439
+ - test/unit/store_test.rb
440
+ - test/unit/tracer_test.rb
441
+ - test/unit/tracked_request_test.rb
442
+ - test/unit/transaction_test.rb
443
+ - test/unit/transaction_time_consumed_test.rb
444
+ - test/unit/utils/active_record_metric_name_test.rb
445
+ - test/unit/utils/backtrace_parser_test.rb
446
+ - test/unit/utils/numbers_test.rb
447
+ - test/unit/utils/scm.rb