Class: AppMap::Config::Package

Inherits:
Struct
  • Object
show all
Defined in:
lib/appmap/config.rb

Overview

Specifies a code path to be mapped. Options:

  • gem may indicate a gem name that “owns” the path

  • package_name can be used to make sure that the code is required so that it can be loaded. This is generally used with builtins, or when the path to be required is not automatically required when bundler requires the gem.

  • exclude can be used used to exclude sub-paths. Generally not used with gem.

  • labels is used to apply labels to matching code. This is really only useful when the package will be applied to specific functions, via TargetMethods.

  • shallow indicates shallow mapping, in which only the entrypoint to a gem is recorded.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#excludeObject

Returns the value of attribute exclude

Returns:

  • (Object)

    the current value of exclude



19
20
21
# File 'lib/appmap/config.rb', line 19

def exclude
  @exclude
end

#gemObject

Returns the value of attribute gem

Returns:

  • (Object)

    the current value of gem



19
20
21
# File 'lib/appmap/config.rb', line 19

def gem
  @gem
end

#handler_classObject



26
27
28
29
# File 'lib/appmap/config.rb', line 26

def handler_class
  require 'appmap/handler/function'
  @handler_class || AppMap::Handler::Function
end

#labelsObject

Returns the value of attribute labels

Returns:

  • (Object)

    the current value of labels



19
20
21
# File 'lib/appmap/config.rb', line 19

def labels
  @labels
end

#package_nameObject

Returns the value of attribute package_name

Returns:

  • (Object)

    the current value of package_name



19
20
21
# File 'lib/appmap/config.rb', line 19

def package_name
  @package_name
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



19
20
21
# File 'lib/appmap/config.rb', line 19

def path
  @path
end

#shallowObject

Returns the value of attribute shallow

Returns:

  • (Object)

    the current value of shallow



19
20
21
# File 'lib/appmap/config.rb', line 19

def shallow
  @shallow
end

Class Method Details

.build_from_gem(gem, shallow: true, package_name: nil, exclude: [], labels: [], optional: false, force: false) ⇒ Object

Builds a package for gem. Generally corresponds to a ‘gem:` entry in appmap.yml. Also used when mapping a builtin.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/appmap/config.rb', line 47

def build_from_gem(gem, shallow: true, package_name: nil, exclude: [], labels: [], optional: false, force: false)
  if !force && %w[method_source activesupport].member?(gem)
    warn "WARNING: #{gem} cannot be AppMapped because it is a dependency of the appmap gem"
    return
  end
  path = gem_path(gem, optional)
  if path
    Package.new(path, gem, package_name, exclude, labels, shallow)
  else
    warn "#{gem} is not available in the bundle" if AppMap::Hook::LOG
  end
end

.build_from_path(path, shallow: false, package_name: nil, exclude: [], labels: []) ⇒ Object

Builds a package for a path, such as ‘app/models` in a Rails app. Generally corresponds to a `path:` entry in appmap.yml. Also used for mapping specific methods via TargetMethods.



41
42
43
# File 'lib/appmap/config.rb', line 41

def build_from_path(path, shallow: false, package_name: nil, exclude: [], labels: [])
  Package.new(path, nil, package_name, exclude, labels, shallow)
end

Instance Method Details

#nameObject



72
73
74
# File 'lib/appmap/config.rb', line 72

def name
  gem || path
end

#shallow?Boolean

Indicates that only the entry points to a package will be recorded. Once the code has entered a package, subsequent calls within the package will not be recorded unless the code leaves the package and re-enters it.

Returns:

  • (Boolean)


34
35
36
# File 'lib/appmap/config.rb', line 34

def shallow?
  shallow
end

#to_hObject



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/appmap/config.rb', line 76

def to_h
  {
    path: path,
    package_name: package_name,
    gem: gem,
    handler_class: handler_class.name,
    exclude: exclude.blank? ? nil : exclude,
    labels: labels.blank? ? nil : labels,
    shallow: shallow
  }.compact
end