-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for HTTPS compression #190
Conversation
raise Exception("could not scrub the payload") | ||
if DD_USE_COMPRESSION: | ||
try: | ||
data = compress_logs(str(data), DD_COMPRESSION_LEVEL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to convert the data to a string here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll recompress the same batch over and over on retries, we could probably do the compression outside of this method to avoid extra computations on network errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and removed the try block.
For the casting to string, I was getting some type errors for a while from the gzip.compress
function when trying to convert data
to bytes and casting it to a string first seemed to fix it. I just tried again though without it and everything works ok. Must have been some other error I fixed inadvertently. 🤷♂
Cleaning up redundant syntax
5d319d0
to
e8a5b92
Compare
else: | ||
compression_level = level | ||
|
||
return gzip.compress(bytes(batch, 'utf-8'), compression_level) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this method throw an error ? If so, we probably want to catch it here https://github.com/DataDog/datadog-serverless-functions/pull/190/files#diff-618731ddf1c446ef45d09613cb4b189bR339 to avoid retrying indefinitely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks nice, thanks for working on this, I think we could probably have moved the encoding logic in DatadogClient
to avoid re-encoding the payload for each retry.
I took a stab at putting the compression in I think that error gets solved when the compression happens in |
What does this PR do?
Adds support for compression when sending logs over HTTPS.
Motivation
Now that the function sends logs over HTTPS by default we should allow users to compress the logs.