How to use the datadog-metrics.BufferedMetricsLogger 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 Xetera / hifumi / bot / src / analytics / datadog.ts View on Github external
import { BufferedMetricsLogger } from "datadog-metrics";
import { AkairoClient } from "discord-akairo";
import { countMembers, logger } from "../utils";

const { HIFUMI_DATADOG_API_KEY } = process.env;

const _dd = new BufferedMetricsLogger({
  apiKey: HIFUMI_DATADOG_API_KEY || "disabled in development",
  host: "hifumi",
  prefix: "hifumi.",
  // allows us to buffer stats and send them in bulk
  flushIntervalSeconds: 15,
});

/**
 * Wrapper function that prevents calling metrics in development mode
 * @param func
 */
export const withDatadog = (func: (client: BufferedMetricsLogger) => void): void => {
  if (HIFUMI_DATADOG_API_KEY) {
    func(_dd);
  }
};
github auth0 / auth0-instrumentation / lib / metrics_factory.js View on Github external
function buildDataDog(pkg, env) {
  const dd = new datadog.BufferedMetricsLogger({
    apiKey: env.METRICS_API_KEY,
    host: env.METRICS_HOST || require('os').hostname(),
    prefix: utils.buildMetricPrefix(env, pkg),
    flushIntervalSeconds: env.METRICS_FLUSH_INTERVAL || 15
  });

  return new DatadogClientToStatsdAdapter(dd);
}
github artilleryio / artillery-plugin-publish-metrics / lib / datadog.js View on Github external
priority: 'low',
      alertType: 'info',
      tags: []
    },
    config.event);

  debug('creating DatadogReporter with config');
  debug(config.apiKey ?
        Object.assign({ apiKey: sanitize(config.apiKey) }, config) :
        config);

  this.config = config;
  if (config.apiKey) {
    debug('Initializing datadog via HTTPS');

    this.metrics = new datadogMetrics.BufferedMetricsLogger({
      apiKey: config.apiKey,
      prefix: config.prefix,
      defaultTags: config.tags,
      flushIntervalSeconds: 5
    });

    this.reportingType = 'api';
  } else if (config.host && config.port) {
    debug('Initializing datadog via agent');
    const options = {
      host: config.host,
      port: config.port,
      prefix: config.prefix,
      globalTags: config.tags,
      bufferFlushInterval: 1000
    };

datadog-metrics

Buffered metrics reporting via the Datadog HTTP API

MIT
Latest version published 11 days ago

Package Health Score

89 / 100
Full package analysis