Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: OTEL_EXPORTER_JAEGER_TIMEOUT env var #881

Merged
merged 2 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AgentExporter

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)
Expand All @@ -23,6 +24,7 @@ def initialize(host: ENV.fetch('OTEL_EXPORTER_JAEGER_AGENT_HOST', 'localhost'),
@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.
Expand All @@ -35,6 +37,7 @@ def initialize(host: ENV.fetch('OTEL_EXPORTER_JAEGER_AGENT_HOST', 'localhost'),
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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def self.ssl_verify_mode
def initialize(endpoint: ENV.fetch('OTEL_EXPORTER_JAEGER_ENDPOINT', 'http://localhost:14268/api/traces'),
username: ENV['OTEL_EXPORTER_JAEGER_USER'],
password: ENV['OTEL_EXPORTER_JAEGER_PASSWORD'],
timeout: ENV.fetch('OTEL_EXPORTER_JAEGER_TIMEOUT', 10),
ssl_verify_mode: CollectorExporter.ssl_verify_mode)
raise ArgumentError, "invalid url for Jaeger::CollectorExporter #{endpoint}" if invalid_url?(endpoint)
raise ArgumentError, 'username and password should either both be nil or both be set' if username.nil? != password.nil?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
exporter = OpenTelemetry::Exporter::Jaeger::AgentExporter.new(host: '127.0.0.1', port: 6831)
_(exporter).wont_be_nil
end

it 'sets parameters from the environment' do
exp = with_env('OTEL_EXPORTER_JAEGER_TIMEOUT' => '42') do
OpenTelemetry::Exporter::Jaeger::AgentExporter.new
end
_(exp.instance_variable_get(:@timeout)).must_equal 42.0
end

it 'prefers explicit parameters rather than the environment' do
exp = with_env('OTEL_EXPORTER_JAEGER_TIMEOUT' => '42') do
OpenTelemetry::Exporter::Jaeger::AgentExporter.new(timeout: 60)
end
_(exp.instance_variable_get(:@timeout)).must_equal 60.0
end
end

describe '#export' do
Expand Down