Skip to content

Commit 01b19aa

Browse files
committed
init: start/end_time fields
1 parent 2474504 commit 01b19aa

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

ack_backend/src/logging_decorators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def wrapper(message, created_at_formatted_string):
5858
additional_log_data = {
5959
"file_key": file_key,
6060
"message_id": message_id,
61+
"batch_start_time": message.get("batch_start_time", "unknown"),
62+
"operation_start_time": message.get("operation_start_time", "unknown"),
63+
"operation_end_time": message.get("operation_end_time", "unknown"),
6164
"vaccine_type": message.get("vaccine_type", "unknown"),
6265
"supplier": message.get("supplier", "unknown"),
6366
"local_id": message.get("local_id", "unknown"),

backend/src/forwarding_batch_lambda.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ def forward_request_to_dynamo(
6060
def forward_lambda_handler(event, _):
6161
"""Forward each row to the Imms API"""
6262
logger.info("Processing started")
63+
batch_start_time = str(datetime.now())
6364
table = create_table()
6465
filename_to_events_mapper = BatchFilenameToEventsMapper()
6566
array_of_identifiers = []
6667
controller = make_batch_controller()
6768

6869
for record in event["Records"]:
6970
try:
71+
operation_start_time = str(datetime.now())
7072
kinesis_payload = record["kinesis"]["data"]
7173
decoded_payload = base64.b64decode(kinesis_payload).decode("utf-8")
7274
incoming_message_body = json.loads(decoded_payload, use_decimal=True)
@@ -103,11 +105,21 @@ def forward_lambda_handler(event, _):
103105
array_of_identifiers.append(identifier)
104106

105107
imms_id = forward_request_to_dynamo(incoming_message_body, table, identifier_already_present, controller)
106-
filename_to_events_mapper.add_event({**base_outgoing_message_body, "imms_id": imms_id})
108+
filename_to_events_mapper.add_event(
109+
{ **base_outgoing_message_body,
110+
"batch_start_time": batch_start_time,
111+
"operation_start_time": operation_start_time,
112+
"operation_end_time": str(datetime.now()),
113+
"imms_id": imms_id }
114+
)
107115

108116
except Exception as error: # pylint: disable = broad-exception-caught
109117
filename_to_events_mapper.add_event(
110-
{**base_outgoing_message_body, "diagnostics": create_diagnostics_dictionary(error)}
118+
{ **base_outgoing_message_body,
119+
"batch_start_time": batch_start_time,
120+
"operation_start_time": operation_start_time,
121+
"operation_end_time": str(datetime.now()),
122+
"diagnostics": create_diagnostics_dictionary(error) }
111123
)
112124
logger.error("Error processing message: %s", error)
113125

0 commit comments

Comments
 (0)