2.0.1 • Published 1 year ago
rstreams-metrics v2.0.1
An wrapper around sending metrics to AWS or DataDog
Create a reporter
import AWS from "aws-sdk";
import { DynamicMetricReporter } from "rstreams-metrics";
export const reporter: DynamicMetricReporter = new DynamicMetricReporter((async () => {
let secret = await new AWS.SecretsManager({ region: process.env.AWS_REGION })
.getSecretValue({ SecretId: "GlobalRSFMetricConfigs" })
.promise();
let config = JSON.parse(secret.SecretString);
return config;
})());
Using the reporter
await reporter.start();
reporter.log({
id: "my.custom.metric",
value: Math.floor(Math.random() * 100),
tags: {
customTag1: "tag-value-1",
customTag2: "tag-value-2"
}
});
await reporter.end();
start
needs to be called to initialze a grouping of metrics and end
needs to be called to flush all stats
Notes for the Cloud
When running in a lambda, start
and end
should be called at the start and end of the lambda handler. Howerver, the reporter can be constructed outside the hander.
2.0.1
1 year ago
2.0.0
1 year ago
1.0.6-beta
3 years ago
1.0.8-beta
3 years ago
1.0.5-beta
3 years ago
1.0.7-beta
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago