Skip to content

Commit

Permalink
[client] Adapt logging strategy to improve the error management
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-julien committed Jan 8, 2025
1 parent 3284e1e commit 5fce0a9
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions pycti/utils/opencti_stix2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2570,9 +2570,6 @@ def import_item(
in_retry = processing_count < PROCESSING_COUNT
# Platform is under heavy load, wait for unlock & retry indefinitely.
if ERROR_TYPE_LOCK in error_msg:
worker_logger.info(
"Message reprocess for lock rejection", {"count": processing_count}
)
bundles_lock_error_counter.add(1)
sleep_jitter = round(random.uniform(1, 3), 2)
time.sleep(sleep_jitter)
Expand All @@ -2581,10 +2578,6 @@ def import_item(
)
# Platform detects a missing reference and have to retry
elif ERROR_TYPE_MISSING_REFERENCE in error_msg and in_retry:
worker_logger.info(
"Message reprocess for missing reference",
{"count": processing_count},
)
bundles_missing_reference_error_counter.add(1)
sleep_jitter = round(random.uniform(1, 3), 2)
time.sleep(sleep_jitter)
Expand All @@ -2593,8 +2586,7 @@ def import_item(
)
# A bad gateway error occurs
elif ERROR_TYPE_BAD_GATEWAY in error_msg:
worker_logger.error("A connection error occurred")
worker_logger.info(
worker_logger.error(
"Message reprocess for bad gateway",
{"count": processing_count},
)
Expand All @@ -2605,8 +2597,7 @@ def import_item(
)
# Request timeout error occurs
elif ERROR_TYPE_TIMEOUT in error_msg:
worker_logger.error("A connection error occurred")
worker_logger.info(
worker_logger.error(
"Message reprocess for request timed out",
{"count": processing_count},
)
Expand All @@ -2619,10 +2610,6 @@ def import_item(
# That also works for missing reference with too much execution
else:
bundles_technical_error_counter.add(1)
worker_logger.error(
"Error executing import",
{"count": processing_count, "reason": error},
)
if work_id is not None:
item_str = json.dumps(item)
self.opencti.work.report_expectation(
Expand Down

0 comments on commit 5fce0a9

Please sign in to comment.