scout_apm 2.1.28 → 2.1.29

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
  SHA1:
3
- metadata.gz: 22f54f5575e5fa0642c1cf7ff44765a6e0c98d1a
4
- data.tar.gz: eeb667d66ae69e342b2de1edc62ec475bcfa253c
3
+ metadata.gz: 6a05b91b0cb840bd278bee2f470494b5e5a85a32
4
+ data.tar.gz: a6d75703bd477570ceb40c31dd230f0ca57657ba
5
5
  SHA512:
6
- metadata.gz: fb7d3f65c107e6b9f1a09e4def243b10827f061160f9a38426ee1d66b8e19f22d971f337bcdf22acf844492c3838c261ce87874f95a636ccc17e4c03aeb66093
7
- data.tar.gz: 62e63d73def12c4eca6f27f724cf6d06b3945aa8ebb467c76015032b6942279beade0c262969b147142018a10351cef5a9539ee6ea2f465ae1fcafc8d46a4adb
6
+ metadata.gz: 7677505dc87d23ce4cbe362bcf6ceced27cd484af214e8563e7b37f215885c8fdb314e70c56252e4968cbf11892aec9e9003e04e37947ba9512d3a6ce8e2daa2
7
+ data.tar.gz: 0cb53c39bd75b62a931b8c55125554cd364982231b94c89657eb6d4f89baa8ff46fc8dbe91aa7c24aed6027128c68cd4568ac4b26eaf1c7b9c2f8c190d2f218f
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.1.29
2
+
3
+ * Add `scm_subdirectory` option. Useful for when your app code does not live in your SCM root directory.
4
+
1
5
  # 2.1.28
2
6
 
3
7
  * Changes to app server load data
@@ -25,6 +25,7 @@ require 'scout_apm/environment'
25
25
  # profile - turn on/off scoutprof (only applicable in Gem versions including scoutprof)
26
26
  # proxy - an http proxy
27
27
  # report_format - 'json' or 'marshal'. Marshal is legacy and will be removed.
28
+ # scm_subdirectory - if the app root lives in source management in a subdirectory. E.g. #{SCM_ROOT}/src
28
29
  # uri_reporting - 'path' or 'full_path' default is 'full_path', which reports URL params as well as the path.
29
30
  #
30
31
  # Any of these config settings can be set with an environment variable prefixed
@@ -53,6 +54,7 @@ module ScoutApm
53
54
  'profile',
54
55
  'proxy',
55
56
  'report_format',
57
+ 'scm_subdirectory',
56
58
  'uri_reporting',
57
59
  ]
58
60
 
@@ -215,6 +217,7 @@ module ScoutApm
215
217
  'log_level' => 'info',
216
218
  'profile' => true, # for scoutprof
217
219
  'report_format' => 'json',
220
+ 'scm_subdirectory' => '',
218
221
  'uri_reporting' => 'full_path',
219
222
  }.freeze
220
223
 
@@ -84,6 +84,14 @@ module ScoutApm
84
84
  end
85
85
  end
86
86
 
87
+ def scm_subdirectory
88
+ @scm_subdirectory ||= if Agent.instance.config.value('scm_subdirectory').empty?
89
+ ''
90
+ else
91
+ Agent.instance.config.value('scm_subdirectory').sub(/^\//, '') # Trim any leading slash
92
+ end
93
+ end
94
+
87
95
  def root
88
96
  @root ||= framework_root
89
97
  end
@@ -24,7 +24,7 @@ module ScoutApm
24
24
  stack = []
25
25
  call_stack.each do |c|
26
26
  if m = c.match(@@app_dir_regex)
27
- stack << m[1]
27
+ stack << ScoutApm::Utils::Scm.relative_scm_path(m[1])
28
28
  break if stack.size == APP_FRAMES
29
29
  end
30
30
  end
@@ -0,0 +1,14 @@
1
+ # Module for helping to deal with Source Code Management settings
2
+ module ScoutApm
3
+ module Utils
4
+ class Scm
5
+ # Takes an *already relative* path +path+
6
+ # Returns a relative path, prepending the configured +scm_subdirectory+ environment string
7
+ def self.relative_scm_path(path, scm_subdirectory = ScoutApm::Environment.instance.scm_subdirectory)
8
+ @@scm_subdirectory ||= scm_subdirectory.sub(/^\//, '')
9
+ @@scm_subdirectoy_blank ||= @@scm_subdirectory.empty?
10
+ @@scm_subdirectoy_blank ? path : File.join(@@scm_subdirectory, path)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.1.28"
2
+ VERSION = "2.1.29"
3
3
  end
4
4
 
data/lib/scout_apm.rb CHANGED
@@ -94,6 +94,7 @@ require 'scout_apm/utils/backtrace_parser'
94
94
  require 'scout_apm/utils/installed_gems'
95
95
  require 'scout_apm/utils/klass_helper'
96
96
  require 'scout_apm/utils/null_logger'
97
+ require 'scout_apm/utils/scm'
97
98
  require 'scout_apm/utils/sql_sanitizer'
98
99
  require 'scout_apm/utils/time'
99
100
  require 'scout_apm/utils/unique_id'
@@ -39,6 +39,11 @@ class BacktraceParserTest < Minitest::Test
39
39
  end
40
40
  end
41
41
 
42
+ def test_calls_scm_relative_path
43
+ ScoutApm::Utils::Scm.expects(:relative_scm_path).at_least_once
44
+ assert ScoutApm::Utils::BacktraceParser.new(raw_backtrace, root).call
45
+ end
46
+
42
47
  def test_works_on_shorter_backtraces
43
48
  result = ScoutApm::Utils::BacktraceParser.new(raw_backtrace(1), root).call
44
49
 
@@ -0,0 +1,17 @@
1
+ require_relative '../../test_helper'
2
+ require 'scout_apm/utils/scm'
3
+
4
+ class ScmTest < Minitest::Test
5
+
6
+ def test_relative_scm_path_blank
7
+ assert_equal 'app/models/person.rb', ScoutApm::Utils::Scm.relative_scm_path('app/models/person.rb', '')
8
+ end
9
+
10
+ def test_relative_scm_path_not_blank
11
+ assert_equal 'src/app/models/person.rb', ScoutApm::Utils::Scm.relative_scm_path('app/models/person.rb', 'src')
12
+ end
13
+
14
+ def test_relative_scm_path_not_blank_with_slashes
15
+ assert_equal 'src/app/models/person.rb', ScoutApm::Utils::Scm.relative_scm_path('app/models/person.rb', '/src/')
16
+ end
17
+ end
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: 2.1.28
4
+ version: 2.1.29
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: 2017-08-01 00:00:00.000000000 Z
12
+ date: 2017-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -234,6 +234,7 @@ files:
234
234
  - lib/scout_apm/utils/klass_helper.rb
235
235
  - lib/scout_apm/utils/null_logger.rb
236
236
  - lib/scout_apm/utils/numbers.rb
237
+ - lib/scout_apm/utils/scm.rb
237
238
  - lib/scout_apm/utils/sql_sanitizer.rb
238
239
  - lib/scout_apm/utils/sql_sanitizer_regex.rb
239
240
  - lib/scout_apm/utils/sql_sanitizer_regex_1_8_7.rb
@@ -267,6 +268,7 @@ files:
267
268
  - test/unit/utils/active_record_metric_name_test.rb
268
269
  - test/unit/utils/backtrace_parser_test.rb
269
270
  - test/unit/utils/numbers_test.rb
271
+ - test/unit/utils/scm.rb
270
272
  homepage: https://github.com/scoutapp/scout_apm_ruby
271
273
  licenses:
272
274
  - Proprietary (See LICENSE.md)