2.0.1 • Published 28 days 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
28 days ago
2.0.0
29 days ago
1.0.6-beta
2 years ago
1.0.8-beta
2 years ago
1.0.5-beta
2 years ago
1.0.7-beta
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago