chore: disabled metrics saving in cloudwatch without removing metrics endpoint

This commit is contained in:
hatskier
2022-07-07 18:02:18 +02:00
parent 71efa599d4
commit 78671ff9f9

View File

@@ -1,22 +1,26 @@
import AWS from "aws-sdk";
// import AWS from "aws-sdk";
import { logger } from "../helpers/logger";
import { isProduction } from "../config";
// import { isProduction } from "../config";
export const saveMetric = async ({ label, value }) => {
if (isProduction) {
const cloudwatch = new AWS.CloudWatch({apiVersion: "2010-08-01"});
// We disabled saving metrics in cloudwatch because of
// rapidly growing costs. We've switched to our self-hosted
// metrics storage in oracle-monitoring instances
logger.info("Metric saving in AWS cloudwatch skipped");
// if (isProduction) {
// const cloudwatch = new AWS.CloudWatch({apiVersion: "2010-08-01"});
const metricParams = {
MetricData: [{
MetricName: label,
Value: value,
}],
Namespace: "CustomPerformanceMetrics",
};
// const metricParams = {
// MetricData: [{
// MetricName: label,
// Value: value,
// }],
// Namespace: "CustomPerformanceMetrics",
// };
await cloudwatch.putMetricData(metricParams).promise();
} else {
logger.info(
"Metric saving in AWS cloudwatch skipped in non-prod environment");
}
// await cloudwatch.putMetricData(metricParams).promise();
// } else {
// logger.info(
// "Metric saving in AWS cloudwatch skipped in non-prod environment");
// }
};