Class: Brut::FrontEnd::Handlers::InstrumentationHandler::Span
- Inherits:
-
Data
- Object
- Data
- Brut::FrontEnd::Handlers::InstrumentationHandler::Span
- Defined in:
- lib/brut/front_end/handlers/instrumentation_handler.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#end_timestamp ⇒ Object
readonly
Returns the value of attribute end_timestamp.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#spans ⇒ Object
readonly
Returns the value of attribute spans.
-
#start_timestamp ⇒ Object
readonly
Returns the value of attribute start_timestamp.
Class Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes
12 13 14 |
# File 'lib/brut/front_end/handlers/instrumentation_handler.rb', line 12 def attributes @attributes end |
#end_timestamp ⇒ Object (readonly)
Returns the value of attribute end_timestamp
12 13 14 |
# File 'lib/brut/front_end/handlers/instrumentation_handler.rb', line 12 def @end_timestamp end |
#events ⇒ Object (readonly)
Returns the value of attribute events
12 13 14 |
# File 'lib/brut/front_end/handlers/instrumentation_handler.rb', line 12 def events @events end |
#name ⇒ Object (readonly)
Returns the value of attribute name
12 13 14 |
# File 'lib/brut/front_end/handlers/instrumentation_handler.rb', line 12 def name @name end |
#spans ⇒ Object (readonly)
Returns the value of attribute spans
12 13 14 |
# File 'lib/brut/front_end/handlers/instrumentation_handler.rb', line 12 def spans @spans end |
#start_timestamp ⇒ Object (readonly)
Returns the value of attribute start_timestamp
12 13 14 |
# File 'lib/brut/front_end/handlers/instrumentation_handler.rb', line 12 def @start_timestamp end |
Class Method Details
.from_header(header_value) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/brut/front_end/handlers/instrumentation_handler.rb', line 23 def self.from_header(header_value) if header_value.nil? return nil end if header_value.kind_of?(self) return header_value end # This header can have info for several vendors, delimited by commas. We pick # out ours, which has a vendor name 'brut' brut_state = header_value.split(/\s*,\s*/).map { it.split(/\s*=\s*/) }.detect { |vendor,_| vendor == "brut" }[1] # Our state is a base-64 encoded JSON blob # each key/value separated by a colon. json = Base64.decode64(brut_state) hash = JSON.parse(json) if !hash.kind_of?(Hash) SemanticLogger[self.class].info "Got a #{hash.class} and not a Hash" return nil end self.from_json(hash) end |
.from_json(json) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/brut/front_end/handlers/instrumentation_handler.rb', line 13 def self.from_json(json) name = json["name"] = Time.at(json["start_timestamp"].to_i / 1000.0) = Time.at(json["end_timestamp"].to_i / 1000.0) attributes = json["attributes"] || {} events = (json["events"] || []).map { Event.from_json(it) } spans = (json["spans"] || []).map { Span.from_json(it) } self.new(name:,start_timestamp:,end_timestamp:,attributes:,events:,spans:) end |