lib/opentelemetry/exporter/jaeger/agent_exporter.rb in opentelemetry-exporter-jaeger-0.19.0 vs lib/opentelemetry/exporter/jaeger/agent_exporter.rb in opentelemetry-exporter-jaeger-0.20.0
- old
+ new
@@ -13,18 +13,20 @@
FAILURE = OpenTelemetry::SDK::Trace::Export::FAILURE
private_constant(:SUCCESS, :FAILURE)
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
# Called to export sampled {OpenTelemetry::SDK::Trace::SpanData} structs.
#
# @param [Enumerable<OpenTelemetry::SDK::Trace::SpanData>] span_data the
@@ -33,9 +35,10 @@
# @param [optional Numeric] timeout An optional timeout in seconds.
# @return [Integer] the result of the export.
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)