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
: ::String.
-
#version ⇒ Object
readonly
: ::String.
Instance Method Summary collapse
-
#initialize(kind:, name:, version:, path:, extra_paths:) ⇒ Library
constructor
A new instance of Library.
-
#path ⇒ Object
: () -> ::String.
-
#to_json(arg = nil) ⇒ Object
: (?::JSON::State?) -> ::String.
Constructor Details
#initialize(kind:, name:, version:, path:, extra_paths:) ⇒ Library
Returns a new instance of Library.
178 179 180 181 182 183 184 185 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 178 def initialize(kind:, name:, version:, path:, extra_paths:) extra_paths = Array(extra_paths).compact.reject(&:empty?).map { |p| p.dup.freeze } @kind = kind.freeze @name = name.dup.freeze @version = version.to_s.dup.freeze @paths = [path.dup.freeze, *extra_paths].freeze freeze end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
168 169 170 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 168 def kind @kind end |
#name ⇒ Object (readonly)
: ::String
169 170 171 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 169 def name @name end |
#version ⇒ Object (readonly)
: ::String
170 171 172 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 170 def version @version end |
Instance Method Details
#path ⇒ Object
: () -> ::String
193 194 195 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 193 def path @paths.first end |
#to_json(arg = nil) ⇒ Object
: (?::JSON::State?) -> ::String
188 189 190 |
# File 'lib/datadog/profiling/collectors/code_provenance.rb', line 188 def to_json(arg = nil) {kind: @kind, name: @name, version: @version, paths: @paths}.to_json(arg) end |