Skip to content

Commit 53db977

Browse files
set custom namespace
1 parent 9e96b04 commit 53db977

3 files changed

Lines changed: 548 additions & 3 deletions

File tree

lambdas/upsert-letter/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dependencies": {
3+
"@aws-sdk/client-cloudwatch": "^3.972.0",
34
"@aws-sdk/client-dynamodb": "^3.858.0",
45
"@aws-sdk/lib-dynamodb": "^3.858.0",
56
"@internal/datastore": "*",

lambdas/upsert-letter/src/handler/upsert-handler.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ import {
2020
} from "@nhsdigital/nhs-notify-event-schemas-letter-rendering";
2121
import z from "zod";
2222
import { Unit, metricScope } from "aws-embedded-metrics";
23+
import {
24+
CloudWatchClient,
25+
PutMetricDataCommand,
26+
} from "@aws-sdk/client-dynamodb";
2327
import { Deps } from "../config/deps";
2428

29+
const cwClient = new CloudWatchClient({ region: "eu-west-2" });
30+
2531
type SupplierSpec = { supplierId: string; specId: string };
2632
type PreparedEvents = LetterRequestPreparedEventV2 | LetterRequestPreparedEvent;
2733
type UpsertOperation = {
@@ -158,6 +164,7 @@ export default function createUpsertLetterHandler(deps: Deps): SQSHandler {
158164
return async (event: SQSEvent) => {
159165
console.log("The SQSEvent:", event);
160166
const batchItemFailures: SQSBatchItemFailure[] = [];
167+
metrics.setNamespace("vlasis_upsertLetter");
161168

162169
const tasks = event.Records.map(async (record) => {
163170
try {
@@ -181,6 +188,7 @@ export default function createUpsertLetterHandler(deps: Deps): SQSHandler {
181188
OperationType: operation.name,
182189
});
183190
metrics.setProperty("operation", operation.name);
191+
184192
metrics.putMetric("MessagesProcessed", 1, Unit.Count);
185193
} catch (error) {
186194
deps.logger.error(

0 commit comments

Comments
 (0)