export async function registerMetric()

in lib/cwmetrics/src/lib/cloudwatch.ts [14:42]


export async function registerMetric(metricName: KnownMetric, value: number) {
	const req = new PutMetricDataCommand({
		Namespace: 'RecipeBackend',
		MetricData: [
			{
				MetricName: metricName,
				Dimensions: [
					{
						Name: 'Stack',
						Value: process.env['STACK'],
					},
					{
						Name: 'Stage',
						Value: process.env['STAGE'],
					},
				],
				Timestamp: new Date(),
				Value: value,
			},
		],
	});

	const response = await cwClient.send(req);
	console.debug(
		`Updated ${metricName} metric after ${
			response.$metadata.attempts ?? 1
		} attempts`,
	);
}