Class: Instana::Exporter::Otlp::CustomConverter

Inherits:
BaseConverter show all
Defined in:
lib/instana/exporter/otlp/custom_converter.rb

Overview

Converter for Instana SDK custom spans to OTLP format

Instance Method Summary collapse

Methods inherited from BaseConverter

#convert, #initialize

Constructor Details

This class inherits a constructor from Instana::Exporter::Otlp::BaseConverter

Instance Method Details

#convert_attributesObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/instana/exporter/otlp/custom_converter.rb', line 22

def convert_attributes
  attributes = {}
  sdk_data = span[:data]&.[](:sdk) || {}

  # Add standard Instana attributes
  add_attribute(attributes, 'instana.span.type', 'custom')
  add_attribute(attributes, 'instana.sdk.name', sdk_data[:name] || span[:n])
  add_attribute(attributes, 'instana.sdk.type', sdk_data[:type])

  # Add tags directly
  tags = sdk_data.dig(:custom, :tags) || {}
  tags.each do |key, value|
    attributes[key] = value
  end

  attributes
end

#span_nameString

Build OTel-compliant span name for custom (SDK) spans

Formula per SPAN_NAME_PATTERNS.txt Section 7:

Use the user-supplied sdk[:name] when available, otherwise fall back
to the internal span type key (span[:n]).

Returns:

  • (String)

    The span name



17
18
19
20
# File 'lib/instana/exporter/otlp/custom_converter.rb', line 17

def span_name
  sdk_name = span[:data]&.[](:sdk)&.[](:name).to_s.strip
  sdk_name.empty? ? super : sdk_name
end