appmap 0.102.2 → 0.103.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: 7535028ffd94cccfeb167a51005d03d3eb49bdab5e987d08eaaa41040f2ead72
4
- data.tar.gz: 1e447679a5a3b0b690d9db333e4150e28c84c5bc0556f221a959331c16ac259f
3
+ metadata.gz: da7a93e936ce2a43f5003c66a1c690b2a02add786ab25f620b09febeafe64859
4
+ data.tar.gz: f4b5bc2e8aa1fe181900fa31b2d3d1965fdbe79e6f8a4c9122039367c4b8bf40
5
5
  SHA512:
6
- metadata.gz: 9356f03158736805234225c0a0368317658b4d2ad821ca67cb9c2582f5d7ada84a0c36edbbc71a26dab37509bcbc79c3e8bdaa16b64a76468702ccea068d4068
7
- data.tar.gz: 592abd7344c26dbd07a6137aa99bf5b8ba21020569b796b6dcecb06a27a8bc24bb5079f9992d85cb6ebb9c43ab2d05690361dc1bc0e5c9dea52d78594290ebc6
6
+ metadata.gz: 8dc10f3ea70a97280466c1d36c693bf33bb6ef3874ee9fcc42dfd2cb38af04138e7206a434a45218beded2827737e0c34eaefe3ed016acc2d0052d9b04de2465
7
+ data.tar.gz: 6b0d23c664a28695748c83b4229e7321853025db183d100c3ce30ec9f3c4ce98228502fbb9e95e51ebfda22ac6849a73680854f94e4ae968ac22be0d9c0ea0da
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ DisabledByDefault: true
3
+ Exclude:
4
+ - 'lib/**'
5
+ - 'test/**'
6
+ - 'spec/**'
data/.standard.yml ADDED
@@ -0,0 +1 @@
1
+ ruby_version: 2.6
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  dist: focal
3
3
  cache:
4
- - bundle
4
+ - bundler
5
5
  - yarn
6
6
 
7
7
  # Travis pre-installs some Ruby versions. You can see the current list
@@ -10,7 +10,7 @@ cache:
10
10
  # that list to not install rvm and ruby each time.
11
11
  rvm:
12
12
  - 2.6.9
13
- - 2.7.6
13
+ - 2.7.5
14
14
  - 3.0.1 # doesn't show in pre-installed list
15
15
  - 3.1.2
16
16
  - 3.2.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ # [0.103.0](https://github.com/getappmap/appmap-ruby/compare/v0.102.2...v0.103.0) (2023-12-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Drop metadata timestamp ([950d8e6](https://github.com/getappmap/appmap-ruby/commit/950d8e63b87853d8d631f31e70dbf56b76166cec))
7
+
8
+
9
+ ### Features
10
+
11
+ * APPMAP_OUTPUT_DIR ([82fe6d7](https://github.com/getappmap/appmap-ruby/commit/82fe6d7cc5b5672f45739ccaaf40b4b05c8fb074))
12
+ * AppMap.record accepts thread ([9863cc5](https://github.com/getappmap/appmap-ruby/commit/9863cc557f3a32229a6068bcb05df095eaf107a2))
13
+ * Drop extended git info ([1d26cb4](https://github.com/getappmap/appmap-ruby/commit/1d26cb451b8c1cee4cccfd1412ec9d8e8e88a3d9))
14
+ * Ensure existence of the appmap output dir ([3019868](https://github.com/getappmap/appmap-ruby/commit/3019868ad9d08af581a33ce2ea8664e74255ca00))
15
+ * Record around command-labeled methods ([9692e2b](https://github.com/getappmap/appmap-ruby/commit/9692e2b4fdf41bcb0bab96b0040cefe063c520ef))
16
+ * Report metadata timestamp as iso8601 ([56f8a52](https://github.com/getappmap/appmap-ruby/commit/56f8a52b3c5b964e163c9ba6021cf0f44981369e))
17
+
1
18
  ## [0.102.2](https://github.com/getappmap/appmap-ruby/compare/v0.102.1...v0.102.2) (2023-11-07)
2
19
 
3
20
 
data/appmap.gemspec CHANGED
@@ -1,56 +1,55 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'appmap/version'
5
+ require "appmap/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  # ability to parameterize gem name is added intentionally,
9
9
  # to support the possibility of unofficial releases, e.g. during CI tests
10
- spec.name = ENV.fetch('GEM_ALTERNATIVE_NAME', 'appmap')
11
- spec.version = AppMap::VERSION
12
- spec.authors = ['Kevin Gilpin']
13
- spec.email = ['kgilpin@gmail.com']
10
+ spec.name = ENV.fetch("GEM_ALTERNATIVE_NAME", "appmap")
11
+ spec.version = AppMap::VERSION
12
+ spec.authors = ["Kevin Gilpin"]
13
+ spec.email = ["kgilpin@gmail.com"]
14
14
 
15
- spec.required_ruby_version = '>= 2.6.0'
15
+ spec.required_ruby_version = ">= 2.6.0"
16
16
 
17
- spec.summary = "Record the operation of a Ruby program, using the AppLand 'AppMap' format."
18
- spec.homepage = AppMap::URL
19
- spec.license = 'MIT'
17
+ spec.summary = "Record the operation of a Ruby program, using the AppLand 'AppMap' format."
18
+ spec.homepage = AppMap::URL
19
+ spec.license = "MIT"
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = `git ls-files --no-deleted`.split("\n").grep_v(/appmap\.json$/).grep_v(%r{^(spec|test)/})
23
+ spec.files = `git ls-files --no-deleted`.split("\n").grep_v(/appmap\.json$/).grep_v(%r{^(spec|test)/})
24
24
 
25
- spec.bindir = 'exe'
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
 
28
- spec.extensions << 'ext/appmap/extconf.rb'
29
- spec.require_paths = ['lib']
28
+ spec.extensions << "ext/appmap/extconf.rb"
29
+ spec.require_paths = ["lib"]
30
30
 
31
- spec.add_dependency 'method_source'
32
- spec.add_dependency 'reverse_markdown'
31
+ spec.add_dependency "method_source"
32
+ spec.add_dependency "reverse_markdown"
33
33
 
34
- spec.add_runtime_dependency 'activesupport'
35
- spec.add_runtime_dependency 'rack'
34
+ spec.add_runtime_dependency "activesupport"
35
+ spec.add_runtime_dependency "rack"
36
36
 
37
- spec.add_development_dependency 'bundler', '>= 1.16'
38
- spec.add_development_dependency 'minitest', '~> 5.15'
39
- spec.add_development_dependency 'pry-byebug'
40
- spec.add_development_dependency 'rake', '>= 12.3.3'
41
- spec.add_development_dependency 'rake-compiler'
42
- spec.add_development_dependency 'rdoc'
43
- spec.add_development_dependency 'standardrb', "~> 1.0"
37
+ spec.add_development_dependency "bundler", ">= 1.16"
38
+ spec.add_development_dependency "minitest", "~> 5.15"
39
+ spec.add_development_dependency "pry-byebug"
40
+ spec.add_development_dependency "rake", ">= 12.3.3"
41
+ spec.add_development_dependency "rake-compiler"
42
+ spec.add_development_dependency "rdoc"
44
43
 
45
44
  # Testing
46
- spec.add_development_dependency 'climate_control'
47
- spec.add_development_dependency 'diffy'
48
- spec.add_development_dependency 'hashie'
49
- spec.add_development_dependency 'launchy'
50
- spec.add_development_dependency 'random-port', '~> 0.5.1'
51
- spec.add_development_dependency 'rspec'
52
- spec.add_development_dependency 'selenium-webdriver'
53
- spec.add_development_dependency 'timecop'
54
- spec.add_development_dependency 'webdrivers', '~> 4.0'
55
- spec.add_development_dependency 'webrick'
45
+ spec.add_development_dependency "climate_control"
46
+ spec.add_development_dependency "diffy"
47
+ spec.add_development_dependency "hashie"
48
+ spec.add_development_dependency "launchy"
49
+ spec.add_development_dependency "random-port", "~> 0.5.1"
50
+ spec.add_development_dependency "rspec"
51
+ spec.add_development_dependency "selenium-webdriver"
52
+ spec.add_development_dependency "timecop"
53
+ spec.add_development_dependency "webdrivers", "~> 4.0"
54
+ spec.add_development_dependency "webrick"
56
55
  end
data/lib/appmap/agent.rb CHANGED
@@ -1,15 +1,15 @@
1
- require_relative 'version'
2
- require_relative 'hook'
3
- require_relative 'config'
4
- require_relative 'trace'
5
- require_relative 'class_map'
6
- require_relative 'metadata'
7
- require_relative 'util'
8
- require_relative 'open'
1
+ require_relative "version"
2
+ require_relative "hook"
3
+ require_relative "config"
4
+ require_relative "trace"
5
+ require_relative "class_map"
6
+ require_relative "metadata"
7
+ require_relative "util"
8
+ require_relative "open"
9
9
 
10
10
  # load extension
11
- require_relative 'appmap'
12
- require_relative './detect_enabled'
11
+ require_relative "appmap"
12
+ require_relative "detect_enabled"
13
13
 
14
14
  module AppMap
15
15
  class << self
@@ -25,13 +25,17 @@ module AppMap
25
25
  # Sets the configuration. This is only expected to happen once per
26
26
  # Ruby process.
27
27
  def configuration=(config)
28
- warn 'AppMap is already configured' if @configuration && config
28
+ warn "AppMap is already configured" if @configuration && config
29
29
 
30
30
  @configuration = config
31
31
  end
32
32
 
33
+ def output_dir
34
+ ENV["APPMAP_OUTPUT_DIR"] || DEFAULT_APPMAP_DIR
35
+ end
36
+
33
37
  def default_config_file_path
34
- ENV['APPMAP_CONFIG_FILE'] || 'appmap.yml'
38
+ ENV["APPMAP_CONFIG_FILE"] || "appmap.yml"
35
39
  end
36
40
 
37
41
  # Configures AppMap for recording. Default behavior is to configure from
@@ -58,10 +62,10 @@ module AppMap
58
62
  end
59
63
  end
60
64
 
61
- def tracing_enabled?
65
+ def tracing_enabled?(thread: nil)
62
66
  return false unless @tracing
63
67
 
64
- @tracing.enabled?
68
+ @tracing.enabled?(thread_id: thread&.object_id)
65
69
  end
66
70
 
67
71
  # Used to start tracing, stop tracing, and record events.
@@ -69,10 +73,10 @@ module AppMap
69
73
  @tracing ||= Trace::Tracing.new
70
74
  end
71
75
 
72
- # Records the events which occur while processing a block,
73
- # and returns an AppMap as a Hash.
74
- def record
75
- tracer = tracing.trace
76
+ # Records the events which occur while processing a block, and returns an AppMap as a Hash.
77
+ # Recording may optionally capture only a single thread.
78
+ def record(thread: nil)
79
+ tracer = tracing.trace(thread: thread)
76
80
  tracer.enable
77
81
  begin
78
82
  yield
@@ -84,10 +88,10 @@ module AppMap
84
88
  event_list << tracer.next_event.to_h while tracer.event?
85
89
  end
86
90
  {
87
- 'version' => AppMap::APPMAP_FORMAT_VERSION,
88
- 'metadata' => detect_metadata,
89
- 'classMap' => class_map(tracer.event_methods),
90
- 'events' => events
91
+ "version" => AppMap::APPMAP_FORMAT_VERSION,
92
+ "metadata" => detect_metadata,
93
+ "classMap" => class_map(tracer.event_methods),
94
+ "events" => events
91
95
  }
92
96
  end
93
97
 
@@ -110,11 +114,11 @@ module AppMap
110
114
  end
111
115
 
112
116
  def parameter_schema?
113
- ENV['APPMAP_PARAMETER_SCHEMA'] == 'true'
117
+ ENV["APPMAP_PARAMETER_SCHEMA"] == "true"
114
118
  end
115
119
 
116
120
  def explain_queries?
117
- ENV['APPMAP_EXPLAIN_QUERIES'] == 'true'
121
+ ENV["APPMAP_EXPLAIN_QUERIES"] == "true"
118
122
  end
119
123
 
120
124
  def recording_enabled?(recording_method = nil)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'method_source'
3
+ require "method_source"
4
4
 
5
5
  module AppMap
6
6
  class ClassMap
@@ -23,7 +23,7 @@ module AppMap
23
23
  include HasChildren
24
24
 
25
25
  def type
26
- 'package'
26
+ "package"
27
27
  end
28
28
 
29
29
  def to_h
@@ -38,7 +38,7 @@ module AppMap
38
38
  include HasChildren
39
39
 
40
40
  def type
41
- 'class'
41
+ "class"
42
42
  end
43
43
 
44
44
  def to_h
@@ -53,7 +53,7 @@ module AppMap
53
53
  attr_accessor :static, :location, :labels
54
54
 
55
55
  def type
56
- 'function'
56
+ "function"
57
57
  end
58
58
 
59
59
  def to_h
@@ -62,13 +62,34 @@ module AppMap
62
62
  type: type,
63
63
  location: location,
64
64
  static: static,
65
- labels: labels,
65
+ labels: labels
66
66
  }.delete_if { |_, v| v.nil? || v == [] }
67
67
  end
68
68
  end
69
69
  end
70
70
 
71
71
  class << self
72
+ # Labels can be embedded in the function comment. Label format is similar to YARD and JavaDoc.
73
+ # The keyword is @labels or @label. The keyword is followed by space-separated labels.
74
+ # For example:
75
+ # @label provider.authentication security
76
+ # rubocop:disable Metrics/MethodLength
77
+ def parse_labels(comment)
78
+ return [] unless comment
79
+
80
+ comment
81
+ .split("\n")
82
+ .map { |line| line.match(/^\s*#\s*@labels?\s+(.*)/) }
83
+ .compact
84
+ .map { |match| match[1] }
85
+ .inject([]) { |accum, labels|
86
+ accum += labels.split(/\s+/)
87
+ accum
88
+ }
89
+ .sort
90
+ end
91
+ # rubocop:enable Metrics/MethodLength
92
+
72
93
  def build_from_methods(methods)
73
94
  root = Types::Root.new
74
95
  methods.each do |method|
@@ -76,13 +97,13 @@ module AppMap
76
97
  end
77
98
 
78
99
  collapse_package = lambda do |package|
79
- next unless package.type == 'package'
100
+ next unless package.type == "package"
80
101
 
81
- while package.children.length == 1 && package.children.all? { |child| child.type == 'package' }
102
+ while package.children.length == 1 && package.children.all? { |child| child.type == "package" }
82
103
  child = package.children[0]
83
104
  package.children.clear
84
105
  child.children.each { |child| package.children << child }
85
- package.name = [ package.name, child.name ].join('/')
106
+ package.name = [package.name, child.name].join("/")
86
107
  end
87
108
  package.tap do
88
109
  package.children.map(&collapse_package)
@@ -96,20 +117,20 @@ module AppMap
96
117
 
97
118
  def add_function(root, method)
98
119
  object_infos = \
99
- method.package.split('/').map do |name|
120
+ method.package.split("/").map do |name|
100
121
  {
101
122
  name: name,
102
- type: 'package'
123
+ type: "package"
103
124
  }
104
- end + method.class_name.split('::').map do |name|
125
+ end + method.class_name.split("::").map do |name|
105
126
  {
106
127
  name: name,
107
- type: 'class'
128
+ type: "class"
108
129
  }
109
130
  end
110
131
  function_info = {
111
132
  name: method.name,
112
- type: 'function',
133
+ type: "function",
113
134
  static: method.static
114
135
  }
115
136
  location = method.source_location
@@ -118,9 +139,9 @@ module AppMap
118
139
  if location
119
140
  location_file, lineno = location
120
141
  location_file = location_file[Dir.pwd.length + 1..-1] if location_file.index(Dir.pwd) == 0
121
- [ location_file, lineno ].compact.join(':')
142
+ [location_file, lineno].compact.join(":")
122
143
  else
123
- [ method.class_name, method.static ? '.' : '#', method.name ].join
144
+ [method.class_name, method.static ? "." : "#", method.name].join
124
145
  end
125
146
 
126
147
  comment = method.comment
@@ -143,22 +164,6 @@ module AppMap
143
164
  end
144
165
  end
145
166
 
146
- # Labels can be embedded in the function comment. Label format is similar to YARD and JavaDoc.
147
- # The keyword is @labels or @label. The keyword is followed by space-separated labels.
148
- # For example:
149
- # @label provider.authentication security
150
- def parse_labels(comment)
151
- return [] unless comment
152
-
153
- comment
154
- .split("\n")
155
- .map { |line| line.match(/^\s*#\s*@labels?\s+(.*)/) }
156
- .compact
157
- .map { |match| match[1] }
158
- .inject([]) { |accum, labels| accum += labels.split(/\s+/); accum }
159
- .sort
160
- end
161
-
162
167
  def find_or_create(list, info)
163
168
  obj = list.find { |item| item.type == info[:type] && item.name == info[:name] }
164
169
  return obj if obj