Class: Instana::Exporter::Otlp::BaseConverter Abstract
- Inherits:
-
Object
- Object
- Instana::Exporter::Otlp::BaseConverter
- Defined in:
- lib/instana/exporter/otlp/base_converter.rb
Overview
This class is abstract.
Subclasses should override #convert_attributes to provide type-specific attribute conversion logic.
Base class for all OTLP span converters
Provides common interface and shared functionality for converting Instana spans to OpenTelemetry Protocol (OTLP) compatible span data objects.
Direct Known Subclasses
AwsConverter, BackgroundJobConverter, CustomConverter, DatabaseConverter, GraphqlConverter, HttpConverter, MessagingConverter, RailsConverter, RpcConverter
Defined Under Namespace
Classes: Event, InstrumentationScope, ResourceAdapter, SpanData, SpanDataWithEvents, Status
Instance Method Summary collapse
-
#convert ⇒ SpanData, SpanDataWithEvents
Convert the Instana span to OTLP-compatible span data.
-
#initialize(span, resource = nil) ⇒ BaseConverter
constructor
A new instance of BaseConverter.
Constructor Details
#initialize(span, resource = nil) ⇒ BaseConverter
Returns a new instance of BaseConverter.
142 143 144 145 |
# File 'lib/instana/exporter/otlp/base_converter.rb', line 142 def initialize(span, resource = nil) @span = span @resource = resource || Resource.instance end |
Instance Method Details
#convert ⇒ SpanData, SpanDataWithEvents
Convert the Instana span to OTLP-compatible span data
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/instana/exporter/otlp/base_converter.rb', line 150 def convert # Resolve error info once — reused by both status and events error_count = span[:ec].to_i error_msg = error_count.positive? ? : nil stacktrace = error_count.positive? ? convert_stack_trace : nil span_data = SpanData.new( name: span_name, trace_id: format_trace_id(span[:t]), span_id: format_span_id(span[:s]), parent_span_id: format_parent_span_id, resource: resource_adapter, instrumentation_scope: instrumentation_scope, kind: convert_span_kind, start_timestamp: convert_to_unix_nano(span[:ts]), end_timestamp: , attributes: convert_attributes, status: build_status(error_count, error_msg) ) events = build_error_events(error_count, error_msg, stacktrace) return SpanDataWithEvents.new(span_data, events) unless events.empty? span_data end |