Class: OpenTrace::Breadcrumb
- Inherits:
-
Object
- Object
- OpenTrace::Breadcrumb
- Defined in:
- lib/opentrace/breadcrumbs.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(category:, message:, data: nil, level: "info") ⇒ Breadcrumb
constructor
A new instance of Breadcrumb.
- #to_h ⇒ Object
Constructor Details
#initialize(category:, message:, data: nil, level: "info") ⇒ Breadcrumb
Returns a new instance of Breadcrumb.
7 8 9 10 11 12 13 |
# File 'lib/opentrace/breadcrumbs.rb', line 7 def initialize(category:, message:, data: nil, level: "info") @category = category.to_s @message = .to_s @data = data @level = level.to_s @timestamp = Process.clock_gettime(Process::CLOCK_REALTIME) end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
5 6 7 |
# File 'lib/opentrace/breadcrumbs.rb', line 5 def category @category end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/opentrace/breadcrumbs.rb', line 5 def data @data end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
5 6 7 |
# File 'lib/opentrace/breadcrumbs.rb', line 5 def level @level end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/opentrace/breadcrumbs.rb', line 5 def @message end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/opentrace/breadcrumbs.rb', line 5 def @timestamp end |
Instance Method Details
#to_h ⇒ Object
15 16 17 18 19 |
# File 'lib/opentrace/breadcrumbs.rb', line 15 def to_h h = { category: @category, message: @message, level: @level, timestamp: @timestamp } h[:data] = @data if @data h end |