Browse Source

Merge pull request #10 from logzio/fix_max_allowed_size

Fix bug that consumed more logs while draining than Logz.io's bulk limit
opensearch
Roi Rav-Hon 7 years ago
committed by GitHub
parent
commit
06e47c1e64
3 changed files with 8 additions and 4 deletions
  1. +1
    -0
      README.md
  2. +6
    -3
      logzio/sender.py
  3. +1
    -1
      setup.py

+ 1
- 0
README.md View File

@ -127,6 +127,7 @@ LOGGING = {
- appname - Your django app
## Release Notes
- 2.0.3 - Fix bug that consumed more logs while draining than Logz.io's bulk limit
- 2.0.2 - Support for formatted messages (Thanks @johnraz!)
- 2.0.1 - Added __all__ to __init__.py, so support * imports
- 2.0.0 - Production, stable release.


+ 6
- 3
logzio/sender.py View File

@ -11,7 +11,7 @@ if sys.version[0] == '2':
else:
import queue as queue
MAX_BULK_SIZE_IN_BYTES = 3 * 1024 * 1024 # 3 MB
MAX_BULK_SIZE_IN_BYTES = 1 * 1024 * 1024 # 1 MB
def backup_logs(logs):
@ -112,8 +112,11 @@ class LogzioSender:
def _get_messages_up_to_max_allowed_size(self):
logs_list = []
current_size = 0
while not self.queue.empty():
logs_list.append(self.queue.get())
if sys.getsizeof(logs_list) >= MAX_BULK_SIZE_IN_BYTES:
current_log = self.queue.get()
current_size += sys.getsizeof(current_log)
logs_list.append(current_log)
if current_size >= MAX_BULK_SIZE_IN_BYTES:
break
return logs_list

+ 1
- 1
setup.py View File

@ -4,7 +4,7 @@ from setuptools import setup, find_packages
setup(
name="logzio-python-handler",
version='2.0.2',
version='2.0.3',
description="Logging handler to send logs to your Logz.io account with bulk SSL",
keywords="logging handler logz.io bulk https",
author="roiravhon",


Loading…
Cancel
Save