Skip to content

Commit

Permalink
Compress body
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Nov 12, 2023
1 parent 0d054c6 commit 95b6150
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/flipper/cloud/telemetry.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "json"
require "zlib"
require "stringio"
require "forwardable"
require "securerandom"
require "concurrent/timer_task"
Expand Down Expand Up @@ -122,7 +124,19 @@ def post_to_cloud(drained)
})
http_client = @cloud_configuration.http_client
http_client.add_header :schema_version, SCHEMA_VERSION
http_client.post "/telemetry", body
http_client.add_header :content_encoding, 'gzip'
http_client.post "/telemetry", compress(body)
rescue => error
# FIXME: Retry for net/http server errors
logger.debug "name=flipper_telemetry action=post_to_cloud error=#{error.inspect}"
end

def compress(data)
io = StringIO.new
writer = Zlib::GzipWriter.new(io)
writer.write(data)
writer.finish
io.string
end

def pool_options
Expand Down

0 comments on commit 95b6150

Please sign in to comment.