Class: Chronos::Core::Breadcrumb
- Inherits:
-
Object
- Object
- Chronos::Core::Breadcrumb
- Defined in:
- lib/chronos/core/breadcrumb.rb
Overview
Immutable, bounded diagnostic marker attached to an execution.
Constant Summary collapse
- CATEGORIES =
%w(custom log request query external_http cache job).freeze
Instance Method Summary collapse
-
#initialize(attributes, clock = nil, max_bytes = 2048) ⇒ Breadcrumb
constructor
A new instance of Breadcrumb.
- #to_h ⇒ Object
Constructor Details
#initialize(attributes, clock = nil, max_bytes = 2048) ⇒ Breadcrumb
Returns a new instance of Breadcrumb.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chronos/core/breadcrumb.rb', line 21 def initialize(attributes, clock = nil, max_bytes = 2048) attributes = {} unless attributes.is_a?(Hash) clock ||= proc { Time.now } serializer = SafeSerializer.new( :max_depth => 5, :max_keys => 20, :max_items => 20, :max_string_bytes => 512, :max_nodes => 100 ) @data = serializer.call(build_data(attributes, clock)) @data = compact_data(@data, max_bytes) if JSON.generate(@data).bytesize > max_bytes deep_freeze(@data) freeze end |
Instance Method Details
#to_h ⇒ Object
34 35 36 |
# File 'lib/chronos/core/breadcrumb.rb', line 34 def to_h @data end |