Class: OpenTelemetry::Exporter::Jaeger::AgentExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/exporter/jaeger/agent_exporter.rb

Overview

An OpenTelemetry trace exporter that sends spans over UDP as Thrift Compact encoded Jaeger spans.

Instance Method Summary collapse

Constructor Details

#initialize(host: ENV.fetch('OTEL_EXPORTER_JAEGER_AGENT_HOST', 'localhost'), port: ENV.fetch('OTEL_EXPORTER_JAEGER_AGENT_PORT', 6831), max_packet_size: 65_000) ⇒ AgentExporter

Returns a new instance of AgentExporter.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/opentelemetry/exporter/jaeger/agent_exporter.rb', line 16

def initialize(host: ENV.fetch('OTEL_EXPORTER_JAEGER_AGENT_HOST', 'localhost'),
               port: ENV.fetch('OTEL_EXPORTER_JAEGER_AGENT_PORT', 6831),
               max_packet_size: 65_000)
  transport = Transport.new(host, port)
  protocol = ::Thrift::CompactProtocol.new(transport)
  @client = Thrift::Agent::Client.new(protocol)
  @max_packet_size = max_packet_size
  @shutdown = false
  @sizing_transport = SizingTransport.new
  @sizing_protocol = ::Thrift::CompactProtocol.new(@sizing_transport)
end

Instance Method Details

#export(span_data) ⇒ Integer

Called to export sampled SDK::Trace::SpanData structs.

Parameters:

  • span_data (Enumerable<OpenTelemetry::SDK::Trace::SpanData>)

    the list of recorded SDK::Trace::SpanData structs to be exported.

Returns:

  • (Integer)

    the result of the export.



34
35
36
37
38
39
40
41
42
# File 'lib/opentelemetry/exporter/jaeger/agent_exporter.rb', line 34

def export(span_data)
  return FAILURE if @shutdown

  encoded_batches(span_data) do |batch|
    return FAILURE if @shutdown

    @client.emitBatch(batch)
  end
end

#shutdownObject

Called when SDK::Trace::Tracer#shutdown is called, if this exporter is registered to a SDK::Trace::Tracer object.



47
48
49
# File 'lib/opentelemetry/exporter/jaeger/agent_exporter.rb', line 47

def shutdown
  @shutdown = true
end