serverless-plugin-datadog 4.3.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +60 -101
- package/dist/package.json +1 -1
- package/dist/src/env.d.ts +3 -0
- package/dist/src/env.d.ts.map +1 -1
- package/dist/src/env.js +24 -2
- package/dist/src/env.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +103 -14
- package/dist/src/index.js.map +1 -1
- package/dist/src/layer.d.ts +1 -0
- package/dist/src/layer.d.ts.map +1 -1
- package/dist/src/layer.js +15 -1
- package/dist/src/layer.js.map +1 -1
- package/dist/src/layers-gov.json +24 -22
- package/dist/src/layers.json +273 -231
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,11 +1,3 @@
|
|
1
|
-
---
|
2
|
-
title: Datadog Serverless Plugin
|
3
|
-
kind: documentation
|
4
|
-
aliases:
|
5
|
-
- /serverless/serverless_integrations/plugin/
|
6
|
-
dependencies: ["https://github.com/DataDog/serverless-plugin-datadog/blob/master/README.md"]
|
7
|
-
---
|
8
|
-
|
9
1
|
![build](https://github.com/DataDog/serverless-plugin-datadog/workflows/build/badge.svg)
|
10
2
|
[![Code Coverage](https://img.shields.io/codecov/c/github/DataDog/serverless-plugin-datadog)](https://codecov.io/gh/DataDog/serverless-plugin-datadog)
|
11
3
|
[![NPM](https://img.shields.io/npm/v/serverless-plugin-datadog)](https://www.npmjs.com/package/serverless-plugin-datadog)
|
@@ -13,80 +5,78 @@ dependencies: ["https://github.com/DataDog/serverless-plugin-datadog/blob/master
|
|
13
5
|
[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/DataDog/serverless-plugin-datadog/blob/master/LICENSE)
|
14
6
|
|
15
7
|
Datadog recommends the Serverless Framework Plugin for developers using the Serverless Framework to deploy their serverless applications.
|
16
|
-
The plugin automatically enables instrumentation for
|
8
|
+
The plugin automatically enables instrumentation for applications to collect metrics, traces, and logs by:
|
17
9
|
|
18
10
|
- Installing the Datadog Lambda library to your Lambda functions as a Lambda layer.
|
19
11
|
- Installing the Datadog Lambda Extension to your Lambda functions as a Lambda layer (`addExtension`) or subscribing the Datadog Forwarder to your Lambda functions' log groups (`forwarderArn`).
|
20
|
-
- Making the required configuration changes, such as adding environment variables, to your Lambda functions.
|
12
|
+
- Making the required configuration changes, such as adding environment variables or additional tracing layers, to your Lambda functions.
|
21
13
|
|
22
14
|
## Getting started
|
23
15
|
|
24
|
-
To quickly get started, follow the installation instructions for [Python][1]
|
16
|
+
To quickly get started, follow the installation instructions for [Python][1], [Node.js][2], [Ruby][3], [Java][4], [Go][5], or [.NET][6] and view your function's enhanced metrics, traces, and logs in Datadog.
|
17
|
+
|
18
|
+
After installation is complete, configure the [advanced options](https://docs.datadoghq.com/serverless/configuration) to suit your monitoring needs.
|
25
19
|
|
26
20
|
## Upgrade
|
27
21
|
|
28
|
-
Each version of the plugin is published with a [specific set of versions of the Datadog Lambda layers][
|
22
|
+
Each version of the plugin is published with a [specific set of versions of the Datadog Lambda layers][15]. To pick up new features and bug fixes provided by the latest versions of Datadog Lambda layers, upgrade the serverless framework plugin. Test the new version before applying it on your production applications.
|
29
23
|
|
30
|
-
##
|
24
|
+
## Configuration parameters
|
31
25
|
|
32
26
|
To further configure your plugin, use the following custom parameters in your `serverless.yml`:
|
33
27
|
|
34
28
|
| Parameter | Description |
|
35
29
|
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
36
|
-
| `
|
37
|
-
| `
|
38
|
-
| `
|
39
|
-
| `
|
40
|
-
| `
|
41
|
-
| `
|
42
|
-
| `
|
43
|
-
| `
|
44
|
-
| `
|
45
|
-
| `
|
46
|
-
| `
|
47
|
-
| `
|
48
|
-
| `
|
49
|
-
| `enableSourceCodeIntegration` | Enable Datadog source code integration for the function.
|
50
|
-
| `subscribeToApiGatewayLogs` | Enable automatic subscription of the Datadog Forwarder to API Gateway log groups. Defaults to `true`.
|
51
|
-
| `subscribeToHttpApiLogs` | Enable automatic subscription of the Datadog Forwarder to HTTP API log groups. Defaults to `true`.
|
52
|
-
| `subscribeToWebsocketLogs` | Enable automatic subscription of the Datadog Forwarder to WebSocket log groups. Defaults to `true`.
|
53
|
-
| `forwarderArn` |
|
54
|
-
| `
|
55
|
-
| `
|
56
|
-
| `
|
57
|
-
| `
|
58
|
-
| `
|
59
|
-
| `
|
60
|
-
| `
|
61
|
-
| `
|
30
|
+
| `site` | Set which Datadog site to send data to, such as `datadoghq.com` (default), `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, or `ddog-gov.com`. This parameter is required when collecting telemtry using the Datadog Lambda Extension. |
|
31
|
+
| `apiKey` | [Datadog API key][7]. This parameter is required when collecting telemetry using the Datadog Lambda Extension. Alternatively, you can also set the `DATADOG_API_KEY` environment variable in your deployment environment. |
|
32
|
+
| `appKey` | Datadog app key. Only needed when the `monitors` field is defined. Alternatively, you can also set the `DATADOG_APP_KEY` environment variable in your deployment environment. |
|
33
|
+
| `apiKeySecretArn` | An alternative to using the `apiKey` field. The ARN of the secret that is storing the Datadog API key in AWS Secrets Manager. Remember to add the `secretsmanager:GetSecretValue` permission to the Lambda execution role. |
|
34
|
+
| `apiKMSKey` | An alternative to using the `apiKey` field. Datadog API key encrypted using KMS. Remember to add the `kms:Decrypt` permission to the Lambda execution role. |
|
35
|
+
| `env` | Tag your Datadog telemetry with the desired `env`. |
|
36
|
+
| `service` | Tag your Datadog telemetry with the desired `service`. |
|
37
|
+
| `version` | Tag your Datadog telemetry with the desired `version`. |
|
38
|
+
| `enableXrayTracing` | Set `true` to enable X-Ray tracing on the Lambda functions and API Gateway integrations. Defaults to `false`. |
|
39
|
+
| `enableDDTracing` | Enable Datadog tracing on the Lambda function. Defaults to `true`. |
|
40
|
+
| `enableDDLogs` | Enable Datadog log collection using the Lambda Extension. Defaults to `true`. Note: This setting has no effect on logs sent by the Datadog Forwarder. |
|
41
|
+
| `monitors` | When defined, the Datadog plugin configures monitors for the deployed function. Requires setting `DATADOG_API_KEY` and `DATADOG_APP_KEY` in your environment. To learn how to define monitors, see [To Enable and Configure a Recommended Serverless Monitor](#to-enable-and-configure-a-recommended-serverless-monitor). |
|
42
|
+
| `captureLambdaPayload` | [Captures incoming and outgoing AWS Lambda payloads][17] in the Datadog APM spans for Lambda invocations. Defaults to `false`. |
|
43
|
+
| `enableSourceCodeIntegration` | Enable [Datadog source code integration][18] for the function. Defaults to `true`. |
|
44
|
+
| `subscribeToApiGatewayLogs` | Enable automatic subscription of the Datadog Forwarder to API Gateway log groups. Requires setting `forwarderArn`. Defaults to `true`. |
|
45
|
+
| `subscribeToHttpApiLogs` | Enable automatic subscription of the Datadog Forwarder to HTTP API log groups. Requires setting `forwarderArn`. Defaults to `true`. |
|
46
|
+
| `subscribeToWebsocketLogs` | Enable automatic subscription of the Datadog Forwarder to WebSocket log groups. Requires setting `forwarderArn`. Defaults to `true`. |
|
47
|
+
| `forwarderArn` | The ARN of the Datadog Forwarder to be subscribed to the Lambda or API Gateway log groups. |
|
48
|
+
| `addLayers` | 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 so that you can install a specific version of the Datadog Lambda library ([Python][8] or [Node.js][9]). |
|
49
|
+
| `addExtension` | Whether to install the Datadog Lambda Extension as a layer. Defaults to `true`. When enabled, it's required to set the `apiKey` and `site`. |
|
50
|
+
| `exclude` | When set, this plugin ignores all specified functions. Use this parameter if you have any functions that should not include Datadog functionality. Defaults to `[]`. |
|
51
|
+
| `enabled` | When set to `false`, the Datadog plugin stays inactive. Defaults to `true`. You can control this option using an environment variable. For example, use `enabled: ${strToBool(${env:DD_PLUGIN_ENABLED, true})}` to activate/deactivate the plugin during deployment. Alternatively, you can also use the value passed in through `--stage` to control this option—[see example](#disable-plugin-for-particular-environment). |
|
52
|
+
| `customHandler` | When set, the specified handler is set as the handler for all the functions. |
|
53
|
+
| `failOnError` | When set, this plugin throws an error if any custom Datadog monitors fail to create or update. This occurs after deploy, but will cause the result of `serverless deploy` to return a nonzero exit code (to fail user CI). Defaults to `false`. |
|
54
|
+
| `integrationTesting` | Set `true` when running integration tests. This bypasses the validation of the Forwarder ARN and the addition of Datadog Monitor output links. Defaults to `false`. |
|
55
|
+
| `logLevel` | The log level, set to `DEBUG` for extended logging. |
|
62
56
|
|
63
57
|
To use any of these parameters, add a `custom` > `datadog` section to your `serverless.yml` similar to this example:
|
64
58
|
|
65
59
|
```yaml
|
66
60
|
custom:
|
67
61
|
datadog:
|
68
|
-
flushMetricsToLogs: true
|
69
62
|
apiKeySecretArn: "{Datadog_API_Key_Secret_ARN}"
|
70
|
-
apiKMSKey: "{Encrypted_Datadog_API_Key}"
|
71
|
-
addLayers: true
|
72
|
-
logLevel: "info"
|
73
63
|
enableXrayTracing: false
|
74
64
|
enableDDTracing: true
|
75
65
|
enableDDLogs: true
|
76
66
|
subscribeToAccessLogs: true
|
77
67
|
forwarderArn: arn:aws:lambda:us-east-1:000000000000:function:datadog-forwarder
|
78
|
-
enableTags: true
|
79
|
-
injectLogContext: true
|
80
68
|
exclude:
|
81
69
|
- dd-excluded-function
|
82
70
|
```
|
83
71
|
|
84
|
-
|
72
|
+
### Webpack
|
85
73
|
|
86
|
-
|
74
|
+
If you are using a bundler, such as webpack, see [Serverless Tracing and Webpack](https://docs.datadoghq.com/serverless/guide/serverless_tracing_and_webpack/).
|
87
75
|
|
88
76
|
### TypeScript
|
89
77
|
|
78
|
+
You may encounter the error of missing type definitions. To resolve the error, add `datadog-lambda-js` and `dd-trace` to the `devDependencies` list of your project's package.json.
|
79
|
+
|
90
80
|
If you are using serverless-typescript, make sure that `serverless-datadog` is above the `serverless-typescript` entry in your `serverless.yml`. The plugin will automatically detect `.ts` files.
|
91
81
|
|
92
82
|
```yaml
|
@@ -95,49 +85,6 @@ plugins:
|
|
95
85
|
- serverless-typescript
|
96
86
|
```
|
97
87
|
|
98
|
-
If you use TypeScript, you may encounter the error of missing type definitions. A missing type definition happens when you use the prebuilt layers (for example, 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.
|
99
|
-
|
100
|
-
### Webpack
|
101
|
-
|
102
|
-
`dd-trace` is known to be not compatible with webpack due to the use of conditional import and other issues. If using webpack, make sure to mark `datadog-lambda-js` and `dd-trace` as [externals](https://webpack.js.org/configuration/externals/) for webpack, so webpack knows these dependencies will be available in the runtime. You should also remove `datadog-lambda-js` and `dd-trace` from `package.json` and the build process to ensure you're using the versions provided by the Datadog Lambda Layer.
|
103
|
-
|
104
|
-
#### serverless-webpack
|
105
|
-
|
106
|
-
If using `serverless-webpack`, make sure to also exclude `datadog-lambda-js` and `dd-trace` in your `serverless.yml` in addition to declaring them as external in your webpack config file.
|
107
|
-
|
108
|
-
**webpack.config.js**
|
109
|
-
|
110
|
-
```javascript
|
111
|
-
var nodeExternals = require("webpack-node-externals");
|
112
|
-
|
113
|
-
module.exports = {
|
114
|
-
// we use webpack-node-externals to excludes all node deps.
|
115
|
-
// You can manually set the externals too.
|
116
|
-
externals: [nodeExternals(), "dd-trace", "datadog-lambda-js"],
|
117
|
-
};
|
118
|
-
```
|
119
|
-
|
120
|
-
**serverless.yml**
|
121
|
-
|
122
|
-
```yaml
|
123
|
-
custom:
|
124
|
-
webpack:
|
125
|
-
includeModules:
|
126
|
-
forceExclude:
|
127
|
-
- dd-trace
|
128
|
-
- datadog-lambda-js
|
129
|
-
```
|
130
|
-
|
131
|
-
### Forwarder
|
132
|
-
|
133
|
-
The [Datadog Forwarder Lambda function][7] needs to be installed and subscribed to your Lambda functions' log groups. The plugin automatically creates the log subscriptions when the Forwarder's ARN is supplied via the `forwarderArn` option.
|
134
|
-
|
135
|
-
If you run into the following error, double check the supplied Forwarder ARN is correct and ensure it is from the same region and account where your serverless application is deployed.
|
136
|
-
|
137
|
-
```
|
138
|
-
An error occurred: GetaccountapiLogGroupSubscription - Could not execute the lambda function. Make sure you have given CloudWatch Logs permission to execute your function. (Service: AWSLogs; Status Code: 400; Error Code: InvalidParameterException).
|
139
|
-
```
|
140
|
-
|
141
88
|
### Disable Plugin for Particular Environment
|
142
89
|
|
143
90
|
If you'd like to turn off the plugin based on the environment (passed via `--stage`), you can use something similar to the example below.
|
@@ -244,6 +191,12 @@ custom:
|
|
244
191
|
|
245
192
|
## Breaking Changes
|
246
193
|
|
194
|
+
### [v5.0.0](https://github.com/DataDog/serverless-plugin-datadog/releases/tag/v5.0.0)
|
195
|
+
|
196
|
+
- This plugin stops setting tags for Service and ENV, and instead uses environment variables (when used in conjunction with the Datadog Extension).
|
197
|
+
|
198
|
+
v5.0 is compatible with v10+ of the Datadog Extension, and all version of the Datadog Forwarder.
|
199
|
+
|
247
200
|
### [v4.0.0](https://github.com/DataDog/serverless-plugin-datadog/releases/tag/v4.0.0)
|
248
201
|
|
249
202
|
- The Datadog Lambda Extension is now the default mechanism for transmitting telemetry to Datadog.
|
@@ -258,7 +211,7 @@ You can also open an issue for a feature request.
|
|
258
211
|
|
259
212
|
## Contributing
|
260
213
|
|
261
|
-
If you find an issue with this package and have a fix,
|
214
|
+
If you find an issue with this package and have a fix, open a pull request following the [procedures][14].
|
262
215
|
|
263
216
|
## Community
|
264
217
|
|
@@ -272,13 +225,19 @@ This product includes software developed at Datadog (<https://www.datadoghq.com/
|
|
272
225
|
|
273
226
|
[1]: https://docs.datadoghq.com/serverless/installation/python/?tab=serverlessframework
|
274
227
|
[2]: https://docs.datadoghq.com/serverless/installation/nodejs/?tab=serverlessframework
|
275
|
-
[3]: https://docs.datadoghq.com/
|
276
|
-
[4]: https://
|
277
|
-
[5]: https://
|
278
|
-
[6]: https://
|
279
|
-
[7]: https://docs.datadoghq.com/
|
280
|
-
[8]: https://
|
281
|
-
[9]: https://
|
282
|
-
[10]: https://
|
283
|
-
[11]: https://
|
284
|
-
[12]: https://docs.datadoghq.com/
|
228
|
+
[3]: https://docs.datadoghq.com/serverless/installation/ruby/?tab=serverlessframework
|
229
|
+
[4]: https://docs.datadoghq.com/serverless/installation/java/?tab=serverlessframework
|
230
|
+
[5]: https://docs.datadoghq.com/serverless/installation/go/?tab=serverlessframework
|
231
|
+
[6]: https://docs.datadoghq.com/serverless/installation/dotnet/?tab=serverlessframework
|
232
|
+
[7]: https://docs.datadoghq.com/account_management/api-app-keys/#api-keys
|
233
|
+
[8]: https://pypi.org/project/datadog-lambda/
|
234
|
+
[9]: https://www.npmjs.com/package/datadog-lambda-js
|
235
|
+
[10]: https://webpack.js.org/configuration/externals/
|
236
|
+
[11]: https://docs.datadoghq.com/serverless/forwarder/
|
237
|
+
[12]: https://docs.datadoghq.com/serverless/datadog_lambda_library/extension/
|
238
|
+
[13]: https://docs.aws.amazon.com/lambda/latest/dg/using-extensions.html
|
239
|
+
[14]: https://github.com/DataDog/serverless-plugin-datadog/blob/master/CONTRIBUTING.md
|
240
|
+
[15]: https://github.com/DataDog/serverless-plugin-datadog/blob/master/src/layers.json
|
241
|
+
[16]: https://docs.datadoghq.com/tracing/setup_overview/configure_data_security/?tab=mongodb#replace-rules-for-tag-filtering
|
242
|
+
[17]: https://www.datadoghq.com/blog/troubleshoot-lambda-function-request-response-payloads/
|
243
|
+
[18]: https://docs.datadoghq.com/integrations/guide/source-code-integration
|
package/dist/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "serverless-plugin-datadog",
|
3
|
-
"version": "
|
3
|
+
"version": "5.1.0",
|
4
4
|
"description": "Serverless plugin to automatically instrument python and node functions with datadog tracing",
|
5
5
|
"main": "dist/src/index.js",
|
6
6
|
"repository": "https://github.com/DataDog/serverless-plugin-datadog",
|
package/dist/src/env.d.ts
CHANGED
@@ -34,6 +34,9 @@ export interface Configuration {
|
|
34
34
|
subscribeToExecutionLogs: boolean;
|
35
35
|
customHandler?: string;
|
36
36
|
}
|
37
|
+
export declare const ddServiceEnvVar = "DD_SERVICE";
|
38
|
+
export declare const ddEnvEnvVar = "DD_ENV";
|
39
|
+
export declare const ddVersionEnvVar = "DD_VERSION";
|
37
40
|
export declare const ddTagsEnvVar = "DD_TAGS";
|
38
41
|
export declare const defaultConfiguration: Configuration;
|
39
42
|
export declare function setEnvConfiguration(config: Configuration, handlers: FunctionInfo[]): void;
|
package/dist/src/env.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AAQA,OAAO,OAAO,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,YAAY,EAA8B,MAAM,SAAS,CAAC;AAEnE,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,SAAS,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,kBAAkB,EAAE,OAAO,CAAC;IAE5B,iBAAiB,EAAE,OAAO,CAAC;IAE3B,eAAe,EAAE,OAAO,CAAC;IAEzB,YAAY,EAAE,OAAO,CAAC;IAEtB,YAAY,EAAE,OAAO,CAAC;IAGtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAInB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAI7B,UAAU,EAAE,OAAO,CAAC;IAEpB,gBAAgB,EAAE,OAAO,CAAC;IAG1B,2BAA2B,EAAE,OAAO,CAAC;IAGrC,OAAO,EAAE,MA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AA2B,EAAE,OAAO,CAAC;IAGrC,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAA;KAAE,EAAE,CAAC;IAGtD,WAAW,EAAE,OAAO,CAAC;IAErB,qBAAqB,EAAE,OAAO,CAAC;IAE/B,wBAAwB,EAAE,OAAO,CAAC;IAGlC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAcD,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,YAAY,YAAY,CAAC;AAkBtC,eAAO,MAAM,oBAAoB,EAAE,aAkBlC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,QA6FlF;AAMD,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CA0BzD;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,QAgB3D;AAiBD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,WAehD"}
|
package/dist/src/env.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
* Copyright 2021 Datadog, Inc.
|
8
8
|
*/
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
-
exports.hasWebpackPlugin = exports.forceExcludeDepsFromWebpack = exports.getConfig = exports.setEnvConfiguration = exports.defaultConfiguration = exports.ddTagsEnvVar = void 0;
|
10
|
+
exports.hasWebpackPlugin = exports.forceExcludeDepsFromWebpack = exports.getConfig = exports.setEnvConfiguration = exports.defaultConfiguration = exports.ddTagsEnvVar = exports.ddVersionEnvVar = exports.ddEnvEnvVar = exports.ddServiceEnvVar = void 0;
|
11
11
|
const layer_1 = require("./layer");
|
12
12
|
const webpackPluginName = "serverless-webpack";
|
13
13
|
const apiKeyEnvVar = "DD_API_KEY";
|
@@ -21,6 +21,10 @@ const ddMergeXrayTracesEnvVar = "DD_MERGE_XRAY_TRACES";
|
|
21
21
|
const logInjectionEnvVar = "DD_LOGS_INJECTION";
|
22
22
|
const ddLogsEnabledEnvVar = "DD_SERVERLESS_LOGS_ENABLED";
|
23
23
|
const ddCaptureLambdaPayloadEnvVar = "DD_CAPTURE_LAMBDA_PAYLOAD";
|
24
|
+
exports.ddServiceEnvVar = "DD_SERVICE";
|
25
|
+
exports.ddEnvEnvVar = "DD_ENV";
|
26
|
+
exports.ddVersionEnvVar = "DD_VERSION";
|
27
|
+
exports.ddTagsEnvVar = "DD_TAGS";
|
24
28
|
// .NET tracer env variables
|
25
29
|
const ENABLE_PROFILING_ENV_VAR = "CORECLR_ENABLE_PROFILING";
|
26
30
|
const PROFILER_ENV_VAR = "CORECLR_PROFILER";
|
@@ -30,7 +34,11 @@ const CORECLR_ENABLE_PROFILING = "1";
|
|
30
34
|
const CORECLR_PROFILER = "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}";
|
31
35
|
const CORECLR_PROFILER_PATH = "/opt/datadog/Datadog.Trace.ClrProfiler.Native.so";
|
32
36
|
const DD_DOTNET_TRACER_HOME = "/opt/datadog";
|
33
|
-
|
37
|
+
// Java tracer env variables
|
38
|
+
const JAVA_TOOL_OPTIONS_VAR = "JAVA_TOOL_OPTIONS";
|
39
|
+
const JAVA_TOOL_OPTIONS = '-javaagent:"/opt/java/lib/dd-java-agent.jar" -XX:+TieredCompilation -XX:TieredStopAtLevel=1';
|
40
|
+
const JAVA_JMXFETCH_ENABLED_VAR = "DD_JMXFETCH_ENABLED";
|
41
|
+
const JAVA_JMXFETCH_ENABLED = false;
|
34
42
|
exports.defaultConfiguration = {
|
35
43
|
addLayers: true,
|
36
44
|
flushMetricsToLogs: true,
|
@@ -131,6 +139,20 @@ function setEnvConfiguration(config, handlers) {
|
|
131
139
|
throwEnvVariableError("DD_DOTNET_TRACER_HOME", DD_DOTNET_TRACER_HOME, functionName);
|
132
140
|
}
|
133
141
|
}
|
142
|
+
if (type === layer_1.RuntimeType.JAVA) {
|
143
|
+
if (environment[JAVA_TOOL_OPTIONS_VAR] === undefined) {
|
144
|
+
environment[JAVA_TOOL_OPTIONS_VAR] = JAVA_TOOL_OPTIONS;
|
145
|
+
}
|
146
|
+
else if (environment[JAVA_TOOL_OPTIONS_VAR] !== JAVA_TOOL_OPTIONS) {
|
147
|
+
throwEnvVariableError("JAVA_TOOL_OPTIONS", JAVA_TOOL_OPTIONS, functionName);
|
148
|
+
}
|
149
|
+
if (environment[JAVA_JMXFETCH_ENABLED_VAR] === undefined) {
|
150
|
+
environment[JAVA_JMXFETCH_ENABLED_VAR] = JAVA_JMXFETCH_ENABLED;
|
151
|
+
}
|
152
|
+
else if (environment[JAVA_JMXFETCH_ENABLED_VAR] !== JAVA_JMXFETCH_ENABLED) {
|
153
|
+
throwEnvVariableError("DD_JMXFETCH_ENABLED", `${JAVA_JMXFETCH_ENABLED}`, functionName);
|
154
|
+
}
|
155
|
+
}
|
134
156
|
});
|
135
157
|
}
|
136
158
|
exports.setEnvConfiguration = setEnvConfiguration;
|
package/dist/src/env.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,mCAAmE;AAoEnE,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC/C,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AACtD,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,cAAc,GAAG,cAAc,CAAC;AACtC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAC9C,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAClD,MAAM,u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AS,EAAE;QACzB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,iBAAiB,CAAC,KAAK,SAAS,CAAC;AAC9E,CAAC;AAfD,4CAeC"}
|
package/dist/src/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAqChD,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACjC,WAAW,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACzC"}
|
package/dist/src/index.js
CHANGED
@@ -52,6 +52,7 @@ var TagKeys;
|
|
52
52
|
(function (TagKeys) {
|
53
53
|
TagKeys["Service"] = "service";
|
54
54
|
TagKeys["Env"] = "env";
|
55
|
+
TagKeys["Version"] = "version";
|
55
56
|
TagKeys["Plugin"] = "dd_sls_plugin";
|
56
57
|
})(TagKeys || (TagKeys = {}));
|
57
58
|
module.exports = class ServerlessPlugin {
|
@@ -122,11 +123,23 @@ module.exports = class ServerlessPlugin {
|
|
122
123
|
this.debugLogHandlers(handlers);
|
123
124
|
(0, layer_1.applyDotnetTracingLayer)(this.serverless.service, functionInfo, allLayers);
|
124
125
|
}
|
126
|
+
else if (functionInfo.type === layer_1.RuntimeType.JAVA) {
|
127
|
+
this.serverless.cli.log("Adding Java Tracing Layer to functions");
|
128
|
+
this.debugLogHandlers(handlers);
|
129
|
+
(0, layer_1.applyJavaTracingLayer)(this.serverless.service, functionInfo, allLayers);
|
130
|
+
}
|
125
131
|
});
|
126
132
|
}
|
127
133
|
else {
|
128
134
|
this.serverless.cli.log("Skipping adding Lambda Extension Layer");
|
129
135
|
}
|
136
|
+
if (config.addExtension) {
|
137
|
+
this.serverless.cli.log("Adding Datadog Env Vars");
|
138
|
+
this.addDDEnvVars(handlers);
|
139
|
+
}
|
140
|
+
if (config.forwarderArn !== undefined || config.forwarderArn !== undefined) {
|
141
|
+
this.addDDTags(handlers);
|
142
|
+
}
|
130
143
|
let tracingMode = tracing_1.TracingMode.NONE;
|
131
144
|
if (config.enableXrayTracing && config.enableDDTracing) {
|
132
145
|
tracingMode = tracing_1.TracingMode.HYBRID;
|
@@ -167,18 +180,23 @@ module.exports = class ServerlessPlugin {
|
|
167
180
|
this.serverless.cli.log(error);
|
168
181
|
}
|
169
182
|
}
|
170
|
-
|
183
|
+
if (datadogForwarderArn && config.addExtension) {
|
184
|
+
this.serverless.cli.log("Warning: Datadog Lambda Extension and forwarder are both enabled. Only APIGateway log groups will be subscribed to the forwarder.");
|
185
|
+
}
|
186
|
+
this.addTags(handlers, config.enableTags, datadogForwarderArn !== undefined);
|
171
187
|
const simpleGit = yield (0, git_1.newSimpleGit)();
|
172
|
-
if (config.
|
173
|
-
(
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
188
|
+
if (((_a = process.env.DATADOG_API_KEY) !== null && _a !== void 0 ? _a : config.apiKey) === undefined) {
|
189
|
+
this.serverless.cli.log("Skipping installing GitHub integration because Datadog credentials were not found. Please set either DATADOG_API_KEY in your environment, or set the apiKey parameter in Serverless.");
|
190
|
+
}
|
191
|
+
else {
|
192
|
+
if (config.enableSourceCodeIntegration && simpleGit !== undefined && (yield simpleGit.checkIsRepo())) {
|
193
|
+
try {
|
194
|
+
yield this.addSourceCodeIntegration(handlers, simpleGit, ((_b = process.env.DATADOG_API_KEY) !== null && _b !== void 0 ? _b : config.apiKey), config.site);
|
195
|
+
}
|
196
|
+
catch (err) {
|
197
|
+
this.serverless.cli.log(`Error occurred when adding source code integration: ${err}`);
|
198
|
+
return;
|
199
|
+
}
|
182
200
|
}
|
183
201
|
}
|
184
202
|
(0, wrapper_1.redirectHandlers)(handlers, config.addLayers, config.customHandler);
|
@@ -232,15 +250,85 @@ module.exports = class ServerlessPlugin {
|
|
232
250
|
}
|
233
251
|
}
|
234
252
|
}
|
253
|
+
/**
|
254
|
+
* Check for service, env, version, and additional tags at the custom level.
|
255
|
+
* If these don't already exsist on the function level as env vars, adds them as DD_XXX env vars
|
256
|
+
*/
|
257
|
+
addDDEnvVars(handlers) {
|
258
|
+
const provider = this.serverless.service.provider;
|
259
|
+
const service = this.serverless.service;
|
260
|
+
let custom = service.custom;
|
261
|
+
if (custom === undefined) {
|
262
|
+
custom = {};
|
263
|
+
}
|
264
|
+
handlers.forEach(({ handler }) => {
|
265
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
266
|
+
(_a = handler.environment) !== null && _a !== void 0 ? _a : (handler.environment = {});
|
267
|
+
const environment = handler.environment;
|
268
|
+
(_b = provider.environment) !== null && _b !== void 0 ? _b : (provider.environment = {});
|
269
|
+
const providerEnvironment = provider.environment;
|
270
|
+
if ((_c = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _c === void 0 ? void 0 : _c.service) {
|
271
|
+
(_d = environment[env_1.ddServiceEnvVar]) !== null && _d !== void 0 ? _d : (environment[env_1.ddServiceEnvVar] = (_e = providerEnvironment[env_1.ddServiceEnvVar]) !== null && _e !== void 0 ? _e : custom.datadog.service);
|
272
|
+
}
|
273
|
+
if ((_f = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _f === void 0 ? void 0 : _f.env) {
|
274
|
+
(_g = environment[env_1.ddEnvEnvVar]) !== null && _g !== void 0 ? _g : (environment[env_1.ddEnvEnvVar] = (_h = providerEnvironment[env_1.ddEnvEnvVar]) !== null && _h !== void 0 ? _h : custom.datadog.env);
|
275
|
+
}
|
276
|
+
if ((_j = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _j === void 0 ? void 0 : _j.version) {
|
277
|
+
(_k = environment[env_1.ddVersionEnvVar]) !== null && _k !== void 0 ? _k : (environment[env_1.ddVersionEnvVar] = (_l = providerEnvironment[env_1.ddVersionEnvVar]) !== null && _l !== void 0 ? _l : custom.datadog.version);
|
278
|
+
}
|
279
|
+
if ((_m = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _m === void 0 ? void 0 : _m.tags) {
|
280
|
+
(_o = environment[env_1.ddTagsEnvVar]) !== null && _o !== void 0 ? _o : (environment[env_1.ddTagsEnvVar] = (_p = providerEnvironment[env_1.ddTagsEnvVar]) !== null && _p !== void 0 ? _p : custom.datadog.tags);
|
281
|
+
}
|
282
|
+
// default to service and stage if env vars aren't set
|
283
|
+
(_q = environment[env_1.ddServiceEnvVar]) !== null && _q !== void 0 ? _q : (environment[env_1.ddServiceEnvVar] = service.getServiceName());
|
284
|
+
(_r = environment[env_1.ddEnvEnvVar]) !== null && _r !== void 0 ? _r : (environment[env_1.ddEnvEnvVar] = this.serverless.getProvider("aws").getStage());
|
285
|
+
});
|
286
|
+
}
|
287
|
+
/**
|
288
|
+
* Check for service, env, version, and additional tags at the custom level.
|
289
|
+
* If these tags don't already exsist on the function level, adds them as tags
|
290
|
+
*/
|
291
|
+
addDDTags(handlers) {
|
292
|
+
const service = this.serverless.service;
|
293
|
+
let custom = service.custom;
|
294
|
+
if (custom === undefined) {
|
295
|
+
custom = {};
|
296
|
+
}
|
297
|
+
handlers.forEach(({ handler }) => {
|
298
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
299
|
+
var _j, _k, _l;
|
300
|
+
(_a = handler.tags) !== null && _a !== void 0 ? _a : (handler.tags = {});
|
301
|
+
const tags = handler.tags;
|
302
|
+
if ((_b = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _b === void 0 ? void 0 : _b.service) {
|
303
|
+
(_c = tags[_j = TagKeys.Service]) !== null && _c !== void 0 ? _c : (tags[_j] = custom.datadog.service);
|
304
|
+
}
|
305
|
+
if ((_d = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _d === void 0 ? void 0 : _d.env) {
|
306
|
+
(_e = tags[_k = TagKeys.Env]) !== null && _e !== void 0 ? _e : (tags[_k] = custom.datadog.env);
|
307
|
+
}
|
308
|
+
if ((_f = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _f === void 0 ? void 0 : _f.version) {
|
309
|
+
(_g = tags[_l = TagKeys.Version]) !== null && _g !== void 0 ? _g : (tags[_l] = custom.datadog.version);
|
310
|
+
}
|
311
|
+
if ((_h = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _h === void 0 ? void 0 : _h.tags) {
|
312
|
+
const tagsArray = custom.datadog.tags.split(",");
|
313
|
+
tagsArray.forEach((tag) => {
|
314
|
+
var _a;
|
315
|
+
const [key, value] = tag.split(":");
|
316
|
+
if (key && value) {
|
317
|
+
(_a = tags[key]) !== null && _a !== void 0 ? _a : (tags[key] = value);
|
318
|
+
}
|
319
|
+
});
|
320
|
+
}
|
321
|
+
});
|
322
|
+
}
|
235
323
|
/**
|
236
324
|
* Check for service and env tags on provider level (under tags and stackTags),
|
237
325
|
* as well as function level. Automatically create tags for service and env with
|
238
326
|
* properties from deployment configurations if needed; does not override any existing values.
|
239
327
|
*/
|
240
|
-
addTags(handlers, enableTags) {
|
328
|
+
addTags(handlers, enableTags, usingForwarder) {
|
241
329
|
const provider = this.serverless.service.provider;
|
242
330
|
this.serverless.cli.log(`Adding Plugin Version ${package_json_1.version} tag`);
|
243
|
-
if (enableTags) {
|
331
|
+
if (enableTags && usingForwarder) {
|
244
332
|
this.serverless.cli.log(`Adding service and environment tags`);
|
245
333
|
}
|
246
334
|
handlers.forEach(({ handler }) => {
|
@@ -248,7 +336,7 @@ module.exports = class ServerlessPlugin {
|
|
248
336
|
var _h, _j, _k, _l;
|
249
337
|
(_a = handler.tags) !== null && _a !== void 0 ? _a : (handler.tags = {});
|
250
338
|
handler.tags[TagKeys.Plugin] = `v${package_json_1.version}`;
|
251
|
-
if (enableTags) {
|
339
|
+
if (enableTags && usingForwarder) {
|
252
340
|
if (!((_b = provider.tags) === null || _b === void 0 ? void 0 : _b[TagKeys.Service]) && !((_c = provider.stackTags) === null || _c === void 0 ? void 0 : _c[TagKeys.Service])) {
|
253
341
|
(_d = (_h = handler.tags)[_j = TagKeys.Service]) !== null && _d !== void 0 ? _d : (_h[_j] = this.serverless.service.getServiceName());
|
254
342
|
}
|
@@ -266,6 +354,7 @@ module.exports = class ServerlessPlugin {
|
|
266
354
|
return __awaiter(this, void 0, void 0, function* () {
|
267
355
|
const sourceCodeIntegration = new source_code_integration_1.SourceCodeIntegration(apiKey, datadogSite, simpleGit);
|
268
356
|
const gitCommitHash = yield sourceCodeIntegration.uploadGitMetadata();
|
357
|
+
this.serverless.cli.log(`Adding GitHub integration with git commit hash ${gitCommitHash}`);
|
269
358
|
handlers.forEach(({ handler }) => {
|
270
359
|
var _a;
|
271
360
|
(_a = handler.environment) !== null && _a !== void 0 ? _a : (handler.environment = {});
|