How to use statsd-client - 1 common examples

To help you get started, we’ve selected a few statsd-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jembi / openhim-core-js / src / stats.js View on Github external
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") {

statsd-client

Yet another client for Etsy's statsd

ISC
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular statsd-client functions