Skip to content

Commit cf57e81

Browse files
johnnyshieldsarielvalentinfbogsany
authored
feat: Exporter should use gzip compression by default (#934)
* Exporter should use gzip compression by default * Fix spec * Fix tests Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Francis Bogsanyi <[email protected]>
1 parent b375af1 commit cf57e81

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def initialize(endpoint: config_opt('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT', 'OTEL_
4848
certificate_file: config_opt('OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE', 'OTEL_EXPORTER_OTLP_CERTIFICATE'),
4949
ssl_verify_mode: Exporter.ssl_verify_mode,
5050
headers: config_opt('OTEL_EXPORTER_OTLP_TRACES_HEADERS', 'OTEL_EXPORTER_OTLP_HEADERS', default: {}),
51-
compression: config_opt('OTEL_EXPORTER_OTLP_TRACES_COMPRESSION', 'OTEL_EXPORTER_OTLP_COMPRESSION'),
51+
compression: config_opt('OTEL_EXPORTER_OTLP_TRACES_COMPRESSION', 'OTEL_EXPORTER_OTLP_COMPRESSION', default: 'gzip'),
5252
timeout: config_opt('OTEL_EXPORTER_OTLP_TRACES_TIMEOUT', 'OTEL_EXPORTER_OTLP_TIMEOUT', default: 10),
5353
metrics_reporter: nil)
5454
raise ArgumentError, "invalid url for OTLP::Exporter #{endpoint}" if invalid_url?(endpoint)

exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
_(exp.instance_variable_get(:@headers)).must_be_empty
1818
_(exp.instance_variable_get(:@timeout)).must_equal 10.0
1919
_(exp.instance_variable_get(:@path)).must_equal '/v1/traces'
20-
_(exp.instance_variable_get(:@compression)).must_be_nil
20+
_(exp.instance_variable_get(:@compression)).must_equal 'gzip'
2121
http = exp.instance_variable_get(:@http)
2222
_(http.ca_file).must_be_nil
2323
_(http.use_ssl?).must_equal true
@@ -414,7 +414,8 @@
414414
it 'batches per resource' do
415415
etsr = nil
416416
stub_post = stub_request(:post, 'https://localhost:4318/v1/traces').to_return do |request|
417-
etsr = Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceRequest.decode(request.body)
417+
proto = Zlib.gunzip(request.body)
418+
etsr = Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceRequest.decode(proto)
418419
{ status: 200 }
419420
end
420421

@@ -593,7 +594,7 @@
593594
)
594595

595596
assert_requested(:post, 'https://localhost:4318/v1/traces') do |req|
596-
req.body == encoded_etsr
597+
req.body == Zlib.gzip(encoded_etsr)
597598
end
598599
end
599600
end

0 commit comments

Comments
 (0)