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), timeout: ENV.fetch('OTEL_EXPORTER_JAEGER_TIMEOUT', 10), max_packet_size: 65_000) ⇒ AgentExporter

Returns a new instance of AgentExporter.



16
17
18
19
20
21
22
23
24
25
26
27
28
# 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),
               timeout: ENV.fetch('OTEL_EXPORTER_JAEGER_TIMEOUT', 10),
               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)
  @timeout = timeout.to_f
end

Instance Method Details

#export(span_data, timeout: nil) ⇒ 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.

  • timeout (optional Numeric) (defaults to: nil)

    An optional timeout in seconds.

Returns:

  • (Integer)

    the result of the export.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/opentelemetry/exporter/jaeger/agent_exporter.rb', line 37

def export(span_data, timeout: nil)
  return FAILURE if @shutdown

  timeout ||= @timeout
  start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
  encoded_batches(span_data) do |batch|
    return FAILURE if @shutdown || OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)&.zero?

    @client.emitBatch(batch)
  end
end

#force_flush(timeout: nil) ⇒ Object

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

Parameters:

  • timeout (optional Numeric) (defaults to: nil)

    An optional timeout in seconds.



54
55
56
# File 'lib/opentelemetry/exporter/jaeger/agent_exporter.rb', line 54

def force_flush(timeout: nil)
  SUCCESS
end

#shutdown(timeout: nil) ⇒ Object

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

Parameters:

  • timeout (optional Numeric) (defaults to: nil)

    An optional timeout in seconds.



63
64
65
66
# File 'lib/opentelemetry/exporter/jaeger/agent_exporter.rb', line 63

def shutdown(timeout: nil)
  @shutdown = true
  SUCCESS
end