Browse Source

don't open a new https connection for every log flush

opensearch
Zeev Tarantov 5 years ago
parent
commit
965ff76062
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      logzio/sender.py

+ 2
- 1
logzio/sender.py View File

@ -18,6 +18,7 @@ else:
MAX_BULK_SIZE_IN_BYTES = 1 * 1024 * 1024 # 1 MB MAX_BULK_SIZE_IN_BYTES = 1 * 1024 * 1024 # 1 MB
requests_session = requests.Session()
def backup_logs(logs, logger): def backup_logs(logs, logger):
@ -110,7 +111,7 @@ class LogzioSender:
for current_try in range(number_of_retries): for current_try in range(number_of_retries):
should_retry = False should_retry = False
try: try:
response = requests.post(
response = requests_session.post(
self.url, headers=headers, data='\n'.join(logs_list), self.url, headers=headers, data='\n'.join(logs_list),
timeout=self.network_timeout) timeout=self.network_timeout)
if response.status_code != 200: if response.status_code != 200:


Loading…
Cancel
Save