Skip to content

Commit dfbf624

Browse files
even more logging
1 parent 8449e04 commit dfbf624

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

lambdas/supplier-allocator/src/handler/allocate-handler.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,21 @@ function emitDataMetrics(
233233
}
234234

235235
function incrementAllocation(
236-
volumeGroupAllocation: VolumeGroupAllocation,
236+
volumeGroupAllocations: VolumeGroupAllocation,
237237
volumeGroupId: string,
238238
supplierId: string,
239239
allocation: number,
240240
deps: Deps,
241241
) {
242-
const groupAllocations = volumeGroupAllocation.get(volumeGroupId) ?? {};
242+
const groupAllocations = volumeGroupAllocations.get(volumeGroupId) ?? {};
243243
groupAllocations[supplierId] =
244244
(groupAllocations[supplierId] ?? 0) + allocation;
245-
volumeGroupAllocation.set(volumeGroupId, groupAllocations);
245+
volumeGroupAllocations.set(volumeGroupId, groupAllocations);
246246
deps.logger.info({
247247
description: "Updated allocations for volume group and supplier",
248248
volumeGroupId,
249249
groupAllocations,
250+
setVolumeGroupAllocations: volumeGroupAllocations.get(volumeGroupId),
250251
});
251252
}
252253

@@ -283,6 +284,7 @@ async function processSupplierAllocation(
283284
eventId: letterEvent.id,
284285
domainId: letterEvent.data.domainId,
285286
letterVariantId: letterEvent.data.letterVariantId,
287+
existingVolumeGroupAllocations: volumeGroupAllocations,
286288
});
287289
const supplierDetails: SupplierDetails = await getSupplierFromConfig(
288290
letterEvent,
@@ -311,6 +313,10 @@ async function processSupplierAllocation(
311313
} else {
312314
incrementMetric(perAllocationFailure, supplier, priority);
313315
}
316+
deps.logger.info({
317+
description: "Completed supplier allocation logic for letter event",
318+
finalvolumeGroupAllocations: volumeGroupAllocations,
319+
});
314320

315321
// Send to allocated letters queue
316322
const queueUrl = process.env.UPSERT_LETTERS_QUEUE_URL;
@@ -400,6 +406,7 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
400406
letterVariantId: letterEvent.data.letterVariantId,
401407
supplier: supplierAllocationResult.supplier,
402408
priority: supplierAllocationResult.priority,
409+
volumeGroupAllocations,
403410
});
404411
supplier = supplierAllocationResult.supplier;
405412
priority = supplierAllocationResult.priority;
@@ -411,7 +418,7 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
411418
letterVariantId: letterEvent.data.letterVariantId,
412419
supplier,
413420
priority,
414-
volumeGroupAllocations,
421+
volumeGroupAllocations: volumeGroupAllocations.entries(),
415422
});
416423
} catch (error) {
417424
deps.logger.error({
@@ -425,6 +432,12 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
425432
}
426433
});
427434

435+
deps.logger.info({
436+
description: "awaiting completion of supplier allocation tasks for batch",
437+
totalRecords: event.Records.length,
438+
taskCount: tasks.length,
439+
tasks,
440+
});
428441
await Promise.all(tasks);
429442

430443
emitMetrics(perAllocationSuccess, MetricStatus.Success, deps);

lambdas/supplier-allocator/src/services/supplier-quotas.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export async function updateSupplierAllocation(
4343
newAllocation: number,
4444
deps: Deps,
4545
): Promise<void> {
46+
deps.logger.info({
47+
description: "Updating supplier allocation",
48+
volumeGroupId,
49+
supplierId,
50+
newAllocation,
51+
});
4652
await deps.supplierQuotasRepo.updateOverallAllocation(
4753
volumeGroupId,
4854
supplierId,

0 commit comments

Comments
 (0)