Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serverless-plugin-datadog

Package Overview
Dependencies
Maintainers
1
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-plugin-datadog - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

3

dist/env.js

@@ -10,2 +10,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = exports.setEnvConfiguration = exports.defaultConfiguration = void 0;
const apiKeyEnvVar = "DD_API_KEY";

@@ -21,3 +22,3 @@ const apiKeyKMSEnvVar = "DD_KMS_API_KEY";

site: "datadoghq.com",
enableXrayTracing: true,
enableXrayTracing: false,
enableDDTracing: true,

@@ -24,0 +25,0 @@ enableTags: true,

@@ -12,2 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.describeSubscriptionFilters = exports.canSubscribeLogGroup = exports.addCloudWatchForwarderSubscriptions = void 0;
const logGroupKey = "AWS::Logs::LogGroup";

@@ -14,0 +15,0 @@ const logGroupSubscriptionKey = "AWS::Logs::SubscriptionFilter";

@@ -9,2 +9,21 @@ "use strict";

*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -19,9 +38,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -28,0 +40,0 @@ const layers = __importStar(require("./layers.json"));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyLayers = exports.findHandlers = exports.runtimeLookup = exports.RuntimeType = void 0;
var RuntimeType;

@@ -4,0 +5,0 @@ (function (RuntimeType) {

@@ -10,2 +10,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.enableTracing = exports.TracingMode = void 0;
const ddTraceEnabledEnvVar = "DD_TRACE_ENABLED";

@@ -12,0 +13,0 @@ const ddMergeXrayTracesEnvVar = "DD_MERGE_XRAY_TRACES";

@@ -10,2 +10,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.redirectHandlers = exports.jsHandler = exports.jsHandlerWithLayers = exports.pythonHandler = exports.datadogHandlerEnvVar = void 0;
const layer_1 = require("./layer");

@@ -12,0 +13,0 @@ exports.datadogHandlerEnvVar = "DD_LAMBDA_HANDLER";

{
"name": "serverless-plugin-datadog",
"version": "1.1.0",
"version": "2.0.0",
"description": "Serverless plugin to automatically instrument python and node functions with datadog tracing",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -10,45 +10,11 @@ # Datadog Serverless Plugin

This serverless framework plugin automatically installs Datadog Lambda layers to your Python and Node.js Lambda functions to collect custom metrics and traces.
The Datadog serverless framework plugin automatically installs the Datadog Lambda library to your Python and Node.js Lambda functions, and enables the collection of enhanced Lambda metrics, custom metrics, traces, and logs from your Lambda functions.
## Installation
You can install the plugin with one of the following commands or add `serverless-plugin-datadog` to your project's package.json.
Follow the installation instructions for [Python](https://docs.datadoghq.com/serverless/installation/python/?tab=serverlessframework) or [Node.js](https://docs.datadoghq.com/serverless/installation/nodejs/?tab=serverlessframework), and view your function's enhanced metrics, traces and logs in Datadog.
```bash
yarn add --dev serverless-plugin-datadog # Yarn users
npm install --save-dev serverless-plugin-datadog # NPM users
```
Then in your serverless.yml add the following:
```yml
plugins:
- serverless-plugin-datadog
```
## How it works
This plugin attaches the Datadog Lambda Layers for [Node.js](https://github.com/DataDog/datadog-lambda-layer-js) and [Python](https://github.com/DataDog/datadog-lambda-layer-python) to your functions. At deploy time, it redirects to a replacement handler that initializes the Lambda Layers without any required code changes. It also enables X-Ray tracing for your Lambda functions and API Gateways.
**IMPORTANT NOTE:** Because the plugin automatically wraps your Lambda handler function, you do **NOT** need to wrap your handler function as stated in the Node.js and Python Layer documentation.
**Node.js**
```js
module.exports.myHandler = datadog(
// This wrapper is NOT needed when using this plugin
async function myHandler(event, context) {},
);
```
**Python**
```python
@datadog_lambda_wrapper # This wrapper is NOT needed when using this plugin
def lambda_handler(event, context):
```
## Configuration
You can configure the library by add the following section to your `serverless.yml`:
You can configure the plugin by adding the following section to your `serverless.yml`:

@@ -58,41 +24,47 @@ ```yaml

datadog:
# Whether to add the Lambda Layers, or expect the user to bring their own. Defaults to true.
addLayers: true
# The log level, set to DEBUG for extended logging. Defaults to info.
logLevel: "info"
# Send custom metrics via logs with the help of Datadog Forwarder Lambda function (recommended). Defaults to false.
# Send custom metrics via logs with the help of Datadog Forwarder Lambda function (recommended). Defaults to `false`.
# When disabled, the parameter `site` and `apiKey` (or `apiKMSKey` if encrypted) must be set.
flushMetricsToLogs: false
# Which Datadog Site to send data to, only needed when flushMetricsToLogs is false. Defaults to datadoghq.com.
site: datadoghq.com # datadoghq.eu for Datadog EU
# Which Datadog Site to send data to, only needed when flushMetricsToLogs is `false`. Defaults to `datadoghq.com`.
# Set to `datadoghq.eu` for Datadog EU.
site: datadoghq.com
# Datadog API Key, only needed when flushMetricsToLogs is false
# Datadog API Key, only needed when flushMetricsToLogs is false.
apiKey: ""
# Datadog API Key encrypted using KMS, only needed when flushMetricsToLogs is false
# Datadog API Key encrypted using KMS, only needed when flushMetricsToLogs is false.
apiKMSKey: ""
# Whether to install the Datadog Lambda library as a layer. Defaults to `true`.
# Set to `false` when you plan to package the Datadog Lambda library to your function's deployment package on your own.
addLayers: true
# Enable tracing on Lambda functions and API Gateway integrations. Defaults to true
enableXrayTracing: true
# The log level, set to DEBUG for extended logging. Defaults to `info`.
logLevel: "info"
# Enable tracing on Lambda function using dd-trace, datadog's APM library. Requires datadog log forwarder to be set up. Defaults to true.
# Enable X-Ray tracing on the Lambda functions and API Gateway integrations. Defaults to `false`.
enableXrayTracing: false
# Enable Datadog tracing on the Lambda function. Defaults to `true`.
# When enabled, the parameter `forwarder` must be set.
enableDDTracing: true
# When set, the plugin will try to subscribe the lambda's cloudwatch log groups to the forwarder with the given arn.
# When set, automatically subscribe the Lambda functions' CloudWatch log groups to the given Datadog forwarder Lambda function.
forwarder: arn:aws:lambda:us-east-1:000000000000:function:datadog-forwarder
# When set, the plugin will try to automatically tag lambdas with service and env, but will not override existing tags set on function or provider levels. Defaults to true.
# When set, automatically tag the Lambda functions with the `service` and `env` tags using the `service` and `stage` values from the serverless application definition. It does NOT override if a `service` or `env` tag already exists. Defaults to `true`.
enableTags: true
```
`flushMetricsToLogs: true` is recommended for submitting custom metrics via CloudWatch logs with the help of [Datadog Forwarder](https://github.com/DataDog/datadog-serverless-functions/tree/master/aws/logs_monitoring).
## FAQ
### What if I want to provide my own version of `datadog-lambda-layer-js` or `datadog-lambda-layer-python`?
### What if I need to install a specific version of the Datadog Lambda library?
If you have the addLayers option enabled, you may also want to add 'datadog-lambda-js' and 'dd-trace' to the [externals](https://webpack.js.org/configuration/externals/) section of your webpack config. Note that auto instrumentation of libraries that have been webpacked into your bundle won't work, but other tracer features can be used.
Set `addLayers` to false, and then you can install and package a specific version of the Datadog Lambda library ([Python](https://pypi.org/project/datadog-lambda/) or [Node.js](https://www.npmjs.com/package/datadog-lambda-js)) on your own.
### What if I use TypeScript?
You may encounter the error of missing type definitions if you use the prebuilt layers (i.e., set `addLayers` to `true`, which is the default) and need to import helper functions from the `datadog-lambda-js` and `dd-trace` packages to submit custom metrics or instrument a specific function. To resolve the error, add `datadog-lambda-js` and `dd-trace` to the `devDependencies` list of your project's package.json.
### How do I use this with serverless-typescript?

@@ -108,2 +80,6 @@

### What if I use webpack?
You are recommended to use the prebuilt layers (i.e., set `addLayers` to `true`, which is the default), and add `datadog-lambda-js` and `dd-trace` to the [externals](https://webpack.js.org/configuration/externals/) section of your webpack config.
## Opening Issues

@@ -110,0 +86,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc