Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
module.exports.queryDatadog = (event, context, callback) => {
dogapi.initialize({
api_key: 'TODO',
app_key: 'TODO'
});
if (event.request.type === 'IntentRequest') {
processIntent(event.request, event.session)
.then(speechletResponse =>
context.succeed(buildResponse({}, speechletResponse)));
}
};
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 || [])] });
}
}
import dogapi from 'dogapi';
import nconf from 'nconf';
import logger from './logger';
if (nconf.get('DATADOG_APIKEY') && nconf.get('DATADOG_APPKEY')) {
logger.info('Datadog enabled');
dogapi.initialize({
api_key: nconf.get('DATADOG_APIKEY'),
app_key: nconf.get('DATADOG_APPKEY')
});
}
export default function send(metric, value) {
if (dogapi.client.api_key && dogapi.client.app_key) dogapi.metric.send(metric, value);
}