lib/opentelemetry/exporter/jaeger/encoder.rb in opentelemetry-exporter-jaeger-0.21.0 vs lib/opentelemetry/exporter/jaeger/encoder.rb in opentelemetry-exporter-jaeger-0.22.0
- old
+ new
@@ -62,28 +62,38 @@
TYPE => TYPE_MAP[value_key],
value_key => value
)
end
- def encoded_span(span_data) # rubocop:disable Metrics/AbcSize
+ def encoded_span(span_data) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
start_time = span_data.start_timestamp / 1_000
duration = span_data.end_timestamp / 1_000 - start_time
+ tags = encoded_tags(span_data.attributes) +
+ encoded_status(span_data.status) +
+ encoded_kind(span_data.kind) +
+ encoded_instrumentation_scope(span_data.instrumentation_scope)
+
+ dropped_attributes_count = span_data.total_recorded_attributes - span_data.attributes&.size.to_i
+ dropped_events_count = span_data.total_recorded_events - span_data.events&.size.to_i
+ dropped_links_count = span_data.total_recorded_links - span_data.links&.size.to_i
+
+ tags << encoded_tag('otel.dropped_attributes_count', dropped_attributes_count) if dropped_attributes_count.positive?
+ tags << encoded_tag('otel.dropped_events_count', dropped_events_count) if dropped_events_count.positive?
+ tags << encoded_tag('otel.dropped_links_count', dropped_links_count) if dropped_links_count.positive?
+
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' => encoded_tags(span_data.attributes) +
- encoded_status(span_data.status) +
- encoded_kind(span_data.kind) +
- encoded_instrumentation_library(span_data.instrumentation_library),
+ 'tags' => tags,
'logs' => encoded_logs(span_data.events)
)
end
def encoded_kind(kind)
@@ -129,15 +139,23 @@
BOOL => true
)
)
end
- def encoded_instrumentation_library(instrumentation_library)
- return EMPTY_ARRAY unless instrumentation_library
+ def encoded_instrumentation_scope(instrumentation_scope)
+ return EMPTY_ARRAY unless instrumentation_scope
tags = []
- tags << encoded_tag('otel.library.name', instrumentation_library.name) if instrumentation_library.name
- tags << encoded_tag('otel.library.version', instrumentation_library.version) if instrumentation_library.version
+ if instrumentation_scope.name
+ tags << encoded_tag('otel.scope.name', instrumentation_scope.name)
+ tags << encoded_tag('otel.library.name', instrumentation_scope.name)
+ end
+
+ if instrumentation_scope.version
+ tags << encoded_tag('otel.scope.version', instrumentation_scope.version)
+ tags << encoded_tag('otel.library.version', instrumentation_scope.version)
+ end
+
tags
end
def int64(byte_string)
int = byte_string.unpack1('Q>')