Class: Datadog::CI::TestVisibility::Serializers::Base
- Inherits:
-
Object
- Object
- Datadog::CI::TestVisibility::Serializers::Base
- Defined in:
- lib/datadog/ci/test_visibility/serializers/base.rb
Constant Summary collapse
- MINIMUM_TIMESTAMP_NANO =
946684800000000000- MINIMUM_DURATION_NANO =
0- MAXIMUM_DURATION_NANO =
9223372036854775807
Instance Attribute Summary collapse
-
#span ⇒ Object
readonly
Returns the value of attribute span.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
Class Method Summary collapse
Instance Method Summary collapse
- #content_fields ⇒ Object
- #content_map_size ⇒ Object
- #duration ⇒ Object
- #error ⇒ Object
-
#initialize(trace, span) ⇒ Base
constructor
A new instance of Base.
- #meta ⇒ Object
- #metrics ⇒ Object
- #name ⇒ Object
- #parent_id ⇒ Object
- #resource ⇒ Object
- #runtime_id ⇒ Object
- #service ⇒ Object
- #span_id ⇒ Object
- #span_type ⇒ Object
- #start ⇒ Object
- #to_msgpack(packer = nil) ⇒ Object
- #trace_id ⇒ Object
- #type ⇒ Object
-
#valid? ⇒ Boolean
validates according to citestcycle json schema.
- #version ⇒ Object
Constructor Details
#initialize(trace, span) ⇒ Base
Returns a new instance of Base.
14 15 16 17 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 14 def initialize(trace, span) @trace = trace @span = span end |
Instance Attribute Details
#span ⇒ Object (readonly)
Returns the value of attribute span.
12 13 14 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 12 def span @span end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
12 13 14 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 12 def trace @trace end |
Class Method Details
.calculate_content_map_size(fields_list) ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 113 def self.calculate_content_map_size(fields_list) fields_list.reduce(0) do |size, field| if field.is_a?(Hash) size + field.size else size + 1 end end end |
Instance Method Details
#content_fields ⇒ Object
46 47 48 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 46 def content_fields [] end |
#content_map_size ⇒ Object
50 51 52 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 50 def content_map_size 0 end |
#duration ⇒ Object
97 98 99 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 97 def duration @duration ||= duration_nano(@span.duration) end |
#error ⇒ Object
109 110 111 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 109 def error @span.status end |
#meta ⇒ Object
101 102 103 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 101 def @span. end |
#metrics ⇒ Object
105 106 107 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 105 def metrics @span.metrics end |
#name ⇒ Object
81 82 83 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 81 def name @span.name end |
#parent_id ⇒ Object
66 67 68 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 66 def parent_id @span.parent_id end |
#resource ⇒ Object
85 86 87 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 85 def resource @span.resource end |
#runtime_id ⇒ Object
54 55 56 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 54 def runtime_id @trace.runtime_id end |
#service ⇒ Object
89 90 91 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 89 def service @span.service end |
#span_id ⇒ Object
62 63 64 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 62 def span_id @span.id end |
#span_type ⇒ Object
77 78 79 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 77 def span_type @span.type end |
#start ⇒ Object
93 94 95 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 93 def start @start ||= time_nano(@span.start_time) end |
#to_msgpack(packer = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 19 def to_msgpack(packer = nil) packer ||= MessagePack::Packer.new packer.write_map_header(3) write_field(packer, "type") write_field(packer, "version") packer.write("content") packer.write_map_header(content_map_size) content_fields.each do |field| if field.is_a?(Hash) field.each do |field_name, method| write_field(packer, field_name, method) end else write_field(packer, field) end end end |
#trace_id ⇒ Object
58 59 60 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 58 def trace_id @trace.id end |
#type ⇒ Object
70 71 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 70 def type end |
#valid? ⇒ Boolean
validates according to citestcycle json schema
42 43 44 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 42 def valid? required_fields_present? && valid_start_time? && valid_duration? end |
#version ⇒ Object
73 74 75 |
# File 'lib/datadog/ci/test_visibility/serializers/base.rb', line 73 def version 1 end |