How to use dogapi - 10 common examples

To help you get started, we’ve selected a few dogapi 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 dbader / node-datadog-metrics / test / loggers_tests.js View on Github external
it('should allow setting the agent tags', function() {
        var agent = new https.Agent({ keepAlive: true, keepAliveMsecs: 10 });
        var l = new BufferedMetricsLogger({
            reporter: new reporters.DataDogReporter('yolo', 'yolo', agent),
        });
        // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
        dogapi.client.proxy_agent.keepAlive.should.equal(true);
        dogapi.client.proxy_agent.keepAliveMsecs.should.equal(10);
        // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
    });
});
github dbader / node-datadog-metrics / test / loggers_tests.js View on Github external
it('should allow setting the agent tags', function() {
        var agent = new https.Agent({ keepAlive: true, keepAliveMsecs: 10 });
        var l = new BufferedMetricsLogger({
            reporter: new reporters.DataDogReporter('yolo', 'yolo', agent),
        });
        // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
        dogapi.client.proxy_agent.keepAlive.should.equal(true);
        dogapi.client.proxy_agent.keepAliveMsecs.should.equal(10);
        // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
    });
});
github dbader / node-datadog-metrics / lib / reporters.js View on Github external
'ERROR: add_metrics failed: %s (err=%s, status=%s)',
                res, err, status
            );
            if (typeof onError === 'function') {
                onError(err, res, status);
            }
        }
    };

    if (debug.enabled) {
        // Only call stringify when debugging.
        debug('Calling add_metrics with %s', JSON.stringify(series));
    }

    // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
    dogapi.metric.send_all(series, callback);
    // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
};
github dbader / node-datadog-metrics / lib / reporters.js View on Github external
function DataDogReporter(apiKey, appKey, agent) {
    apiKey = apiKey || process.env.DATADOG_API_KEY;
    appKey = appKey || process.env.DATADOG_APP_KEY;

    if (!apiKey) {
        throw new Error('DATADOG_API_KEY environment variable not set');
    }

    // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
    dogapi.initialize({api_key: apiKey, app_key: appKey, proxy_agent: agent });
    // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
}
github artilleryio / artillery-plugin-publish-metrics / test / index.js View on Github external
function checkDatadog() {
    dogapi.metric.query(oneHourAgo, now, query, (err, res) => {
      if (err) debug(err);
      if (res) debug(res);

      if (res && res.status === 'ok' && res.series.length > 0) {
        clearInterval(i);
        t.pass(`Metrics tagged with testId:${testId} are in Datadog`);
        t.end();
      } else {
        elapsed += POLLING_INTERVAL_MS;
        if (elapsed > TIMEOUT_MS) {
          clearInterval(i);
          t.fail(`Timed out waiting for metrics to be available in Datadog (testId: ${testId})`);
          t.end();
        }
      }
    });
github gshackles / alexa-datadog-sample / handler.js View on Github external
import process from 'process';
import dogapi from 'dogapi';
import Promise from 'bluebird';
import { buildSpeechletResponse, buildResponse } from './lib/helpers';

const queryDatadog = Promise.promisify(dogapi.metric.query);

function queryCPU() {
  const now = parseInt(new Date().getTime() / 1000);
  const then = now - 300;
  const query = 'system.cpu.user{*}by{host}';
  
  return queryDatadog(then, now, query)
    .then(res => res.series.map(reading => ({
      name: reading.scope
                   .replace(/^host:/i, '')
                   .replace(/(\..*$)/i, '')
                   .replace(/\W/g, ' '),
      value: reading.pointlist[reading.pointlist.length - 1][1]
    })));
}
github expo / turtle / src / metrics / datadog / index.ts View on Github external
import dogapi from 'dogapi';
import util from 'util';

import config from 'turtle/config';

const datadogSendMetric = util.promisify(dogapi.metric.send);

if (!config.datadog.disabled) {
  dogapi.initialize({
    api_key: config.datadog.apiKey,
    app_key: config.datadog.appKey,
   });
}

const tags = [
  `env:${config.deploymentEnv}`,
  `platform:${config.platform}`,
];

export function sendMetric(name: string, value: number, additionalTags?: string[]) {
  if (!config.datadog.disabled) {
    return datadogSendMetric(name, value, { tags: [...tags, ...(additionalTags || [])] });
github apiaryio / cloudwatch-to-papertrail / index.js View on Github external
}

        var reportMatch = line.message.trim().match(reportRegex);

        if (reportMatch != null) {
          return addLambdaMetrics(reportPoints, reportMatch);
        }
      }
    });

    if (config.datadog === '') {
      logger.close();
      return cb();
    }

    dogapi.metric.send_all(metricPoints, function () {
      dogapi.metric.send_all(reportPoints, function () {
        logger.close();
        cb();
      });
    });
  });
};
github apiaryio / cloudwatch-to-papertrail / index.js View on Github external
dogapi.metric.send_all(metricPoints, function () {
      dogapi.metric.send_all(reportPoints, function () {
        logger.close();
        cb();
      });
    });
  });
github Gravebot / Gravebot / src / datadog.js View on Github external
export default function send(metric, value) {
  if (dogapi.client.api_key && dogapi.client.app_key) dogapi.metric.send(metric, value);
}

dogapi

Datadog API Node.JS Client

MIT
Latest version published 3 years ago

Package Health Score

68 / 100
Full package analysis