Module: OpenTelemetry::Exporter::Jaeger::Encoder Private
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #encoded_instrumentation_library(instrumentation_library) ⇒ Object private
- #encoded_kind(kind) ⇒ Object private
- #encoded_logs(events) ⇒ Object private
- #encoded_process(resource) ⇒ Object private
- #encoded_references(links) ⇒ Object private
-
#encoded_span(span_data) ⇒ Object
private
rubocop:disable Metrics/AbcSize.
- #encoded_status(status) ⇒ Object private
- #encoded_tag(key, value) ⇒ Object private
- #encoded_tags(attributes) ⇒ Object private
- #int64(byte_string) ⇒ Object private
Instance Method Details
#encoded_instrumentation_library(instrumentation_library) ⇒ 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.
133 134 135 136 137 138 139 140 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 133 def encoded_instrumentation_library(instrumentation_library) return EMPTY_ARRAY unless instrumentation_library = [] << encoded_tag('otel.library.name', instrumentation_library.name) if instrumentation_library.name << encoded_tag('otel.library.version', instrumentation_library.version) if instrumentation_library.version end |
#encoded_kind(kind) ⇒ 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.
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 88 def encoded_kind(kind) value = KIND_MAP[kind] return EMPTY_ARRAY unless value Array( Thrift::Tag.new( KEY => 'span.kind', TYPE => Thrift::TagType::STRING, STRING => value ) ) end |
#encoded_logs(events) ⇒ 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.
101 102 103 104 105 106 107 108 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 101 def encoded_logs(events) events&.map do |event| Thrift::Log.new( 'timestamp' => (event..to_f * 1_000_000).to_i, 'fields' => (event.attributes) + ('name' => event.name) ) end end |
#encoded_process(resource) ⇒ 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.
35 36 37 38 39 40 41 42 43 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 35 def encoded_process(resource) service_name = 'unknown' = resource&.attribute_enumerator&.select do |key, value| service_name = value if key == 'service.name' key != 'service.name' end = () Thrift::Process.new('serviceName' => service_name, 'tags' => ) end |
#encoded_references(links) ⇒ 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.
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 110 def encoded_references(links) links&.map do |link| Thrift::SpanRef.new( 'refType' => Thrift::SpanRefType::CHILD_OF, 'traceIdLow' => int64(link.span_context.trace_id[16, 16]), 'traceIdHigh' => int64(link.span_context.trace_id[0, 16]), 'spanId' => int64(link.span_context.span_id) ) end end |
#encoded_span(span_data) ⇒ 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.
rubocop:disable Metrics/AbcSize
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 66 def encoded_span(span_data) # rubocop:disable Metrics/AbcSize start_time = (span_data..to_f * 1_000_000).to_i duration = (span_data..to_f * 1_000_000).to_i - start_time Thrift::Span.new( 'traceIdLow' => int64(span_data.trace_id[8, 8]), 'traceIdHigh' => int64(span_data.trace_id[0, 8]), 'spanId' => int64(span_data.span_id), 'parentSpanId' => int64(span_data.parent_span_id), 'operationName' => span_data.name, 'references' => encoded_references(span_data.links), 'flags' => span_data.trace_flags.sampled? ? 1 : 0, 'startTime' => start_time, 'duration' => duration, 'tags' => (span_data.attributes) + encoded_status(span_data.status) + encoded_kind(span_data.kind) + encoded_instrumentation_library(span_data.instrumentation_library), 'logs' => encoded_logs(span_data.events) ) end |
#encoded_status(status) ⇒ 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.
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 121 def encoded_status(status) return EMPTY_ARRAY unless status&.code == OpenTelemetry::Trace::Status::ERROR Array( Thrift::Tag.new( KEY => 'error', TYPE => Thrift::TagType::BOOL, BOOL => true ) ) end |
#encoded_tag(key, value) ⇒ 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.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 51 def encoded_tag(key, value) value_key = case value when Integer then LONG when Float then DOUBLE when String, Array then STRING when false, true then BOOL end value = value.to_json if value.is_a?(Array) Thrift::Tag.new( KEY => key, TYPE => TYPE_MAP[value_key], value_key => value ) end |
#encoded_tags(attributes) ⇒ 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.
45 46 47 48 49 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 45 def (attributes) attributes&.map do |key, value| encoded_tag(key, value) end || EMPTY_ARRAY end |
#int64(byte_string) ⇒ 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.
142 143 144 145 |
# File 'lib/opentelemetry/exporter/jaeger/encoder.rb', line 142 def int64(byte_string) int = byte_string.unpack1('Q>') int < (1 << 63) ? int : int - (1 << 64) end |