Class: Datadog::Profiling::Collectors::CodeProvenance
- Inherits:
-
Object
- Object
- Datadog::Profiling::Collectors::CodeProvenance
- Defined in:
- lib/datadog/profiling/collectors/code_provenance.rb
Overview
Collects library metadata for loaded files ($LOADED_FEATURES) in the Ruby VM. The output of this class is a list of libraries which have been require’d (in particular, this is not a list of ALL installed libraries).
This metadata powers grouping and categorization of stack trace data.
This class acts both as a collector (collecting data) as well as a recorder (records/serializes it)
Defined Under Namespace
Classes: Library
Instance Method Summary collapse
- #generate ⇒ Object
- #generate_json ⇒ Object
-
#initialize(standard_library_path: RbConfig::CONFIG.fetch("rubylibdir")) ⇒ CodeProvenance
constructor
A new instance of CodeProvenance.
- #refresh(loaded_files: $LOADED_FEATURES, loaded_specs: Gem.loaded_specs.values) ⇒ Object
Constructor Details
#initialize(standard_library_path: RbConfig::CONFIG.fetch("rubylibdir")) ⇒ CodeProvenance
Returns a new instance of CodeProvenance.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 17 def initialize(standard_library_path: RbConfig::CONFIG.fetch("rubylibdir")) @libraries_by_name = {} @libraries_by_path = {} @seen_files = Set.new @seen_libraries = Set.new record_library( Library.new( kind: "standard library", name: "stdlib", version: RUBY_VERSION, path: standard_library_path, ) ) end |
Instance Method Details
#generate ⇒ Object
40 41 42 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 40 def generate seen_libraries end |
#generate_json ⇒ Object
44 45 46 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 44 def generate_json JSON.fast_generate(v1: seen_libraries.to_a) end |
#refresh(loaded_files: $LOADED_FEATURES, loaded_specs: Gem.loaded_specs.values) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 33 def refresh(loaded_files: $LOADED_FEATURES, loaded_specs: Gem.loaded_specs.values) record_loaded_specs(loaded_specs) record_loaded_files(loaded_files) self end |