Skip to content

Commit a0ead45

Browse files
committed
Merge remote branch into local branch VED-740-meta-versionID
2 parents 6fd58ed + 8c73098 commit a0ead45

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

ack_backend/src/logging_decorators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def wrapper(message, created_at_formatted_string):
5858
additional_log_data = {
5959
"file_key": file_key,
6060
"message_id": message_id,
61+
"operation_start_time": message.get("operation_start_time", "unknown"),
62+
"operation_end_time": message.get("operation_end_time", "unknown"),
6163
"vaccine_type": message.get("vaccine_type", "unknown"),
6264
"supplier": message.get("supplier", "unknown"),
6365
"local_id": message.get("local_id", "unknown"),

ack_backend/tests/utils/values_for_ack_backend_tests.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
class DefaultValues:
88
"""Class to hold default values for tests"""
99

10+
fixed_datetime = datetime(2024, 10, 29, 12, 0, 0)
11+
fixed_datetime_str = fixed_datetime.strftime("%Y-%m-%d %H:%M:%S")
12+
1013
message_id = "test_file_id"
1114
row_id = "test_file_id#1"
1215
local_id = "test_system_uri^testabc"
1316
imms_id = "test_imms_id"
1417
operation_requested = "CREATE"
1518
created_at_formatted_string = "20211120T12000000"
19+
operation_start_time = fixed_datetime_str
20+
operation_end_time = fixed_datetime_str
1621

1722

1823
class DiagnosticsDictionaries:
@@ -90,6 +95,8 @@ def __init__(
9095
local_id: str = DefaultValues.local_id,
9196
imms_id: str = DefaultValues.imms_id,
9297
created_at_formatted_string: str = DefaultValues.created_at_formatted_string,
98+
operation_start_time: str = DefaultValues.operation_start_time,
99+
operation_end_time: str = DefaultValues.operation_end_time,
93100
):
94101
self.name = f"{vaccine_type.upper()}/ {supplier.upper()} {operation_requested} message"
95102
self.file_key = f"{vaccine_type}_Vaccinations_v5_{ods_code}_20210730T12000000.csv"
@@ -108,6 +115,8 @@ def __init__(
108115
self.local_id = local_id
109116
self.imms_id = imms_id
110117
self.created_at_formatted_string = created_at_formatted_string
118+
self.operation_start_time = operation_start_time
119+
self.operation_end_time = operation_end_time
111120

112121
self.queue_name = f"{supplier}_{vaccine_type}"
113122

@@ -116,6 +125,8 @@ def __init__(
116125
"supplier": self.supplier,
117126
"vaccine_type": self.vaccine_type,
118127
"created_at_formatted_string": self.created_at_formatted_string,
128+
"operation_start_time": self.operation_start_time,
129+
"operation_end_time": self.operation_end_time,
119130
"row_id": self.row_id,
120131
"local_id": self.local_id,
121132
"operation_requested": self.operation_requested,
@@ -151,6 +162,8 @@ class ValidValues:
151162
mock_message_expected_log_value = {
152163
"function_name": "ack_processor_convert_message_to_ack_row",
153164
"date_time": fixed_datetime.strftime("%Y-%m-%d %H:%M:%S"),
165+
"operation_start_time": MOCK_MESSAGE_DETAILS.operation_start_time,
166+
"operation_end_time": MOCK_MESSAGE_DETAILS.operation_end_time,
154167
"status": "success",
155168
"supplier": MOCK_MESSAGE_DETAILS.supplier,
156169
"file_key": MOCK_MESSAGE_DETAILS.file_key,
@@ -242,6 +255,8 @@ class InvalidValues:
242255
Logging_with_no_values = {
243256
"function_name": "ack_processor_convert_message_to_ack_row",
244257
"date_time": fixed_datetime.strftime("%Y-%m-%d %H:%M:%S"),
258+
"operation_start_time": "unknown",
259+
"operation_end_time": "unknown",
245260
"status": "fail",
246261
"supplier": "unknown",
247262
"file_key": "file_key_missing",

backend/src/forwarding_batch_lambda.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import base64
66
import time
77
import logging
8+
from datetime import datetime
89

910
from batch.batch_filename_to_events_mapper import BatchFilenameToEventsMapper
1011
from fhir_batch_repository import create_table
@@ -67,6 +68,7 @@ def forward_lambda_handler(event, _):
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,19 @@ 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+
"operation_start_time": operation_start_time,
111+
"operation_end_time": str(datetime.now()),
112+
"imms_id": imms_id }
113+
)
107114

108115
except Exception as error: # pylint: disable = broad-exception-caught
109116
filename_to_events_mapper.add_event(
110-
{**base_outgoing_message_body, "diagnostics": create_diagnostics_dictionary(error)}
117+
{ **base_outgoing_message_body,
118+
"operation_start_time": operation_start_time,
119+
"operation_end_time": str(datetime.now()),
120+
"diagnostics": create_diagnostics_dictionary(error) }
111121
)
112122
logger.error("Error processing message: %s", error)
113123

backend/tests/test_forwarding_batch_lambda.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ def test_forward_lambda_handler_groups_and_sends_events_by_filename(self, mock_s
455455
self.assertDictEqual(json.loads(first_call_kwargs["MessageBody"])[0], {
456456
"created_at_formatted_string": "2025-01-24T12:00:00Z",
457457
"file_key": "supplier_1_rsv_test_file",
458+
"operation_start_time": ANY,
459+
"operation_end_time": ANY,
458460
"imms_id": ANY,
459461
"local_id": "local-1",
460462
"operation_requested": "CREATE",
@@ -465,6 +467,8 @@ def test_forward_lambda_handler_groups_and_sends_events_by_filename(self, mock_s
465467
self.assertDictEqual(json.loads(second_call_kwargs["MessageBody"])[0], {
466468
"created_at_formatted_string": "2025-01-24T12:00:00Z",
467469
"file_key": "supplier_2_rsv_test_file",
470+
"operation_start_time": ANY,
471+
"operation_end_time": ANY,
468472
"imms_id": ANY,
469473
"local_id": "local-2",
470474
"operation_requested": "CREATE",

0 commit comments

Comments
 (0)