This commit is contained in:
2025-06-13 15:59:28 -05:00
parent fc6fa76bc0
commit 26adce6ecf
2 changed files with 12 additions and 1 deletions

View File

@@ -55,6 +55,7 @@ def call_api_with_retry(payload, domain, request_id, max_retries=3):
payload_json = json.dumps(payload).encode('utf-8')
for attempt in range(max_retries):
try:
logger.info(f"[{request_id}] Attempt {attempt+1}: POST payload to {sync_url}")
req = urllib.request.Request(sync_url, data=payload_json, method="POST")
req.add_header('Authorization', f'Bearer {API_TOKEN}')
req.add_header('Content-Type', 'application/json')
@@ -65,6 +66,7 @@ def call_api_with_retry(payload, domain, request_id, max_retries=3):
with urllib.request.urlopen(req, timeout=timeout, context=context) as response:
code = response.getcode()
if code == 200:
logger.info(f"[{request_id}] API response: {response_code}")
return True
except urllib.error.HTTPError as e:
if 400 <= e.code < 500:
@@ -113,6 +115,10 @@ def lambda_handler(event, context):
'original_size': len(body),
'compressed_size': len(compressed)
}
logger.info(f"[{request_id}] OUTGOING payload to {API_BASE_URL}/process/{domain}: "
f"domain={domain}, key={key}, bucket={bucket}, "
f"orig_size={len(body)}, comp_size={len(compressed)}")
if call_api_with_retry(payload, domain, request_id):
# Inline metadata marking statt Löschung