Class: StackifyRubyAPM::Serializers::Transactions Private
- Inherits:
-
Serializer
- Object
- Serializer
- StackifyRubyAPM::Serializers::Transactions
- Includes:
- Log
- Defined in:
- lib/stackify_apm/serializers/transactions.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from Log
Instance Method Summary collapse
-
#build_json(config, transaction) ⇒ Object
private
This method will return a Hash object(Transaction).
-
#build_protobuf(config, transaction) ⇒ Object
private
This method will build a Protobuf object.
Methods included from Log
#debug, #error, #fatal, #info, #log, #warn
Methods inherited from Serializer
Constructor Details
This class inherits a constructor from StackifyRubyAPM::Serializers::Serializer
Instance Method Details
#build_json(config, transaction) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method will return a Hash object(Transaction). It will accept Config and Transaction instance.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/stackify_apm/serializers/transactions.rb', line 13 def build_json(config, transaction) root_span_json = { id: -1, call: transaction.name, reqBegin: transaction., reqEnd: transaction.duration, props: RootInfo.build(config, transaction), exceptions: transaction.exceptions, stacks: [] } # serialize all the spans children_spans_json = [] transaction.spans.each do |span| children_spans_json.push(build_span(span)) end add_children_spans(root_span_json, children_spans_json) root_span_json rescue StandardError => e debug "[Transactions::Serializer] build_json() exception: #{e.inspect}" end |
#build_protobuf(config, transaction) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method will build a Protobuf object. It will accept the Config and Transaction instance. Return a Stackify::Trace object.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/stackify_apm/serializers/transactions.rb', line 39 def build_protobuf(config, transaction) root_span_hash = build_json(config, transaction) begin # create Trace object trace = StackifyProtoBuf::Trace.new # create TraceFrame object trace_frame = StackifyProtoBuf::TraceFrame.new trace_frame.call = root_span_hash[:call].to_s trace_frame. = root_span_hash[:reqBegin] trace_frame. = root_span_hash[:reqEnd] exception = StackifyProtoBuf::TraceException.new if root_span_hash[:exceptions].count > 0 ex = root_span_hash[:exceptions] ex.each do |exc| exception.caught_by = exc[:CaughtBy].to_s exception.exception = exc[:Exception].to_s exception. = exc[:Message].to_s exception. = exc[:Timestamp].to_f exc[:Frames].each do |f| trace_ex_frame = StackifyProtoBuf::TraceExceptionFrame.new trace_ex_frame.method = f[:Method].to_s exception.frames.push(trace_ex_frame) end trace_frame.exceptions.push(exception) end end # create props root_frame_props = Google::Protobuf::Map.new(:string, :string) root_span_hash[:props].each { |key, value| root_frame_props[key.to_s] = value.to_s } trace_frame.properties = root_frame_props add_child_frame trace_frame, root_span_hash trace.frame = trace_frame return trace rescue StandardError => e debug "[Serializers::Transactions] build_protobuf() exception: #{e.inspect}" end end |