Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import SDC from "statsd-client";
import logger from "winston";
import os from "os";
import util from "util";
import { config } from "./config";
const statsdServer = config.get("statsd");
const application = config.get("application");
const timer = new Date();
const domain = `${os.hostname()}.${application.name}`;
const sdc = new SDC(statsdServer);
export function incrementTransactionCount(ctx, done) {
logger.info(`sending counts to statsd for ${domain}.${ctx.authorisedChannel._id}`);
const { transactionStatus } = ctx;
try {
sdc.increment(`${domain}.channels`); // Overall Counter
sdc.increment(`${domain}.channels.${transactionStatus}`); // Overall Transaction Status
sdc.increment(`${domain}.channels.${ctx.authorisedChannel._id}`); // Per channel
sdc.increment(`${domain}.channels.${ctx.authorisedChannel._id}.statuses.${transactionStatus}`); // Per Channel Status
if (ctx.mediatorResponse != null) {
// Check for custom mediator metrics
let metric;
if (ctx.mediatorResponse.metrics != null) {
for (metric of Array.from(ctx.mediatorResponse.metrics)) {
if (metric.type === "counter") {