How to use the datadog-metrics.timing function in datadog-metrics

To help you get started, we’ve selected a few datadog-metrics 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 withspectrum / spectrum / shared / statsd.js View on Github external
const handleObjectTags = method => {
    const original = metrics[method];
    metrics[method] = (key, val, tags, timestamp) => {
      return original.call(
        metrics,
        key,
        val,
        Array.isArray(tags) ? tags : stringify(tags),
        timestamp
      );
    };
  };
  handleObjectTags('histogram');
  handleObjectTags('gauge');
  handleObjectTags('increment');
  metrics.timing = (...args) => metrics.histogram.call(metrics, ...args);

  statsd = metrics;
}

function collectMemoryStats() {
  var memory = process.memoryUsage();
  statsd.gauge('memory.rss', memory.rss);
  statsd.gauge('memory.heapTotal', memory.heapTotal);
  statsd.gauge('memory.heapUsed', memory.heapUsed);
}

// Report memory usage every second
setInterval(collectMemoryStats, 1000);

datadog-metrics

Buffered metrics reporting via the Datadog HTTP API

MIT
Latest version published 7 months ago

Package Health Score

82 / 100
Full package analysis