Class: Datadog::Profiling::Collectors::CodeProvenance::Library
- Inherits:
-
Object
- Object
- Datadog::Profiling::Collectors::CodeProvenance::Library
- Defined in:
- lib/datadog/profiling/collectors/code_provenance.rb
Overview
Represents metadata we have for a ruby gem
Important note: This class gets encoded to JSON with the built-in JSON gem. But, we’ve found that in some buggy cases, some Ruby gems monkey patch the built-in JSON gem and forget to call #to_json, and instead encode this class instance-field-by-instance-field.
Thus, this class was setup to match the JSON output. Take this into consideration if you are adding new fields. (Also, we have a spec for this)
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(kind:, name:, version:, path:) ⇒ Library
constructor
A new instance of Library.
- #path ⇒ Object
- #to_json(arg = nil) ⇒ Object
Constructor Details
#initialize(kind:, name:, version:, path:) ⇒ Library
Returns a new instance of Library.
113 114 115 116 117 118 119 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 113 def initialize(kind:, name:, version:, path:) @kind = kind.freeze @name = name.dup.freeze @version = version.to_s.dup.freeze @paths = [path.dup.freeze].freeze freeze end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
111 112 113 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 111 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
111 112 113 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 111 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
111 112 113 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 111 def version @version end |
Instance Method Details
#path ⇒ Object
125 126 127 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 125 def path @paths.first end |
#to_json(arg = nil) ⇒ Object
121 122 123 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 121 def to_json(arg = nil) {kind: @kind, name: @name, version: @version, paths: @paths}.to_json(arg) end |