Skip to content

Commit

Permalink
Compress otlp payload with zlib
Browse files Browse the repository at this point in the history
Fixes #71
  • Loading branch information
wperron committed Feb 2, 2024
1 parent 6e44fe8 commit b91b035
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/opentelemetry/trace/exporter/otlp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local BACKOFF_RETRY_LIMIT = 3
local DEFAULT_TIMEOUT_MS = 10000
local exporter_request_duration_metric = "otel.otlp_exporter.request_duration"
local circuit = require("opentelemetry.trace.exporter.circuit")
local zlib = require("zlib")

local _M = {
}
Expand Down Expand Up @@ -54,8 +55,12 @@ local function call_collector(exporter, pb_encoded_body)
return false, "Circuit breaker is open"
end

-- Compress (deflate) request body
local deflate_stream = zlib.deflate()
local compressed_pb_encoded_body = deflate_stream(pb_encoded_body)

-- Make request
res, res_error = exporter.client:do_request(pb_encoded_body)
res, res_error = exporter.client:do_request(compressed_pb_encoded_body)
local after_time = util.gettimeofday_ms()
otel_global.metrics_reporter:record_value(
exporter_request_duration_metric, after_time - current_time)
Expand Down
1 change: 1 addition & 0 deletions rockspec/opentelemetry-lua-master-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description = {
dependencies = {
"lua-protobuf = 0.3.3",
"lua-resty-http = 0.16.1-0",
"lua-zlib = 1.2",
}

build = {
Expand Down

0 comments on commit b91b035

Please sign in to comment.