serverless-plugin-datadog
Advanced tools
Comparing version
{ | ||
"name": "serverless-plugin-datadog", | ||
"version": "5.90.0", | ||
"version": "5.91.0", | ||
"description": "Serverless plugin to automatically instrument python and node functions with datadog tracing", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -27,3 +27,3 @@ "use strict"; | ||
const WEBSOCKETS_EXECUTION_LOG_GROUP_KEY = "WebsocketsExecutionLogGroup"; | ||
const WEBSOCKETS_EXECUTION_SUBCRIPTION_KEY = "WebsocketsExecutionLogGroupSubscription"; | ||
const WEBSOCKETS_EXECUTION_SUBSCRIPTION_KEY = "WebsocketsExecutionLogGroupSubscription"; | ||
function isLogGroup(value) { | ||
@@ -71,3 +71,3 @@ return value.Type === logGroupKey; | ||
const executionSubscription = subscribeToExecutionLogGroup(functionArn, WEBSOCKETS_EXECUTION_LOG_GROUP_KEY); | ||
resources[WEBSOCKETS_EXECUTION_SUBCRIPTION_KEY] = executionSubscription; | ||
resources[WEBSOCKETS_EXECUTION_SUBSCRIPTION_KEY] = executionSubscription; | ||
} | ||
@@ -74,0 +74,0 @@ }); |
@@ -186,3 +186,3 @@ "use strict"; | ||
afterPackageFunction() { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -211,48 +211,3 @@ const config = (0, env_1.getConfig)(this.serverless.service); | ||
} | ||
if (config.enableStepFunctionsTracing || config.subscribeToStepFunctionLogs) { | ||
const resources = (_a = this.serverless.service.provider.compiledCloudFormationTemplate) === null || _a === void 0 ? void 0 : _a.Resources; | ||
const stepFunctions = Object.values(this.serverless.service.stepFunctions.stateMachines); | ||
if (stepFunctions.length === 0) { | ||
this.serverless.cli.log("subscribeToStepFunctionLogs is set to true but no step functions were found."); | ||
} | ||
else { | ||
this.serverless.cli.log("Subscribing step function log groups to Datadog Forwarder"); | ||
for (const stepFunction of stepFunctions) { | ||
if (!stepFunction.hasOwnProperty("loggingConfig")) { | ||
this.serverless.cli.log(`Creating log group for ${stepFunction.name} and logging to it with level ALL.`); | ||
yield (0, forwarder_1.addStepFunctionLogGroup)(aws, resources, stepFunction); | ||
} | ||
else { | ||
this.serverless.cli.log(`Found logging config for step function ${stepFunction.name}`); | ||
const loggingConfig = stepFunction.loggingConfig; | ||
if (loggingConfig.level !== "ALL") { | ||
loggingConfig.level = "ALL"; | ||
this.serverless.cli.log(`Warning: Setting log level to ALL for step function ${stepFunction.name} so traces can be generated.`); | ||
} | ||
if (loggingConfig.includeExecutionData !== true) { | ||
loggingConfig.includeExecutionData = true; | ||
this.serverless.cli.log(`Warning: Setting includeExecutionData to true for step function ${stepFunction.name} so traces can be generated.`); | ||
} | ||
} | ||
// subscribe step function log group to datadog forwarder regardless of how the log group was created | ||
yield (0, forwarder_1.addStepFunctionLogGroupSubscription)(resources, stepFunction, datadogForwarderArn); | ||
} | ||
} | ||
if (config.mergeStepFunctionAndLambdaTraces || config.propagateTraceContext) { | ||
this.serverless.cli.log(`mergeStepFunctionAndLambdaTraces and propagateTraceContext will be deprecated. Please use propagateUpstreamTrace instead`); | ||
} | ||
if (config.mergeStepFunctionAndLambdaTraces || config.propagateTraceContext || config.propagateUpstreamTrace) { | ||
this.serverless.cli.log(`mergeStepFunctionAndLambdaTraces or propagateUpstreamTrace is true, trying to modify Step Functions' definitions to add trace context.`); | ||
(0, span_link_1.mergeStepFunctionAndLambdaTraces)(resources, this.serverless); | ||
} | ||
} | ||
else { | ||
// Recommend Step Functions instrumentation for customers who do not set enableStepFunctionsTracing to true | ||
try { | ||
(0, step_functions_helper_1.inspectAndRecommendStepFunctionsInstrumentation)(this.serverless); | ||
} | ||
catch (error) { | ||
this.serverless.cli.log(`Error raise when inspecting if there are any uninstrumented Step Functions state machines. Error: ${error}`); | ||
} | ||
} | ||
yield this.instrumentStepFunctions(config, aws, datadogForwarderArn); | ||
for (const error of errors) { | ||
@@ -268,3 +223,3 @@ this.serverless.cli.log(error); | ||
this.logToCliOnce(`Adding source code integration`); | ||
if (((_b = process.env.DATADOG_API_KEY) !== null && _b !== void 0 ? _b : config.apiKey) === undefined) { | ||
if (((_a = process.env.DATADOG_API_KEY) !== null && _a !== void 0 ? _a : config.apiKey) === undefined) { | ||
let keyError; | ||
@@ -289,3 +244,3 @@ if (config.apiKeySecretArn) { | ||
this.logToCliOnce(`Uploading git metadata`); | ||
yield datadog_ci_1.gitMetadata.uploadGitCommitHash(((_c = process.env.DATADOG_API_KEY) !== null && _c !== void 0 ? _c : config.apiKey), config.site); | ||
yield datadog_ci_1.gitMetadata.uploadGitCommitHash(((_b = process.env.DATADOG_API_KEY) !== null && _b !== void 0 ? _b : config.apiKey), config.site); | ||
} | ||
@@ -312,2 +267,65 @@ } | ||
} | ||
/** | ||
* Do the major part of the work for instrumenting step functions. | ||
* This function does not set tags. That is done in afterPackageCompileFunctions(). | ||
*/ | ||
instrumentStepFunctions(config, aws, datadogForwarderArn) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const compiledCfnTemplate = this.serverless.service.provider.compiledCloudFormationTemplate; | ||
// Compiled CloudFormation template may be unavailable if the user only deploys part of the stack. | ||
// See https://github.com/DataDog/serverless-plugin-datadog/issues/593 | ||
// In that case, skip instrumenting step functions. | ||
if (!compiledCfnTemplate) { | ||
this.serverless.cli.log(`Compiled CloudFormation template not found. Skipping instrumenting step functions. | ||
This is expected if you only deploy part of the stack.`); | ||
return; | ||
} | ||
if (config.enableStepFunctionsTracing || config.subscribeToStepFunctionLogs) { | ||
const resources = compiledCfnTemplate.Resources; | ||
const stepFunctions = Object.values(this.serverless.service.stepFunctions.stateMachines); | ||
if (stepFunctions.length === 0) { | ||
this.serverless.cli.log("subscribeToStepFunctionLogs is set to true but no step functions were found."); | ||
} | ||
else { | ||
this.serverless.cli.log("Subscribing step function log groups to Datadog Forwarder"); | ||
for (const stepFunction of stepFunctions) { | ||
if (!stepFunction.hasOwnProperty("loggingConfig")) { | ||
this.serverless.cli.log(`Creating log group for ${stepFunction.name} and logging to it with level ALL.`); | ||
yield (0, forwarder_1.addStepFunctionLogGroup)(aws, resources, stepFunction); | ||
} | ||
else { | ||
this.serverless.cli.log(`Found logging config for step function ${stepFunction.name}`); | ||
const loggingConfig = stepFunction.loggingConfig; | ||
if (loggingConfig.level !== "ALL") { | ||
loggingConfig.level = "ALL"; | ||
this.serverless.cli.log(`Warning: Setting log level to ALL for step function ${stepFunction.name} so traces can be generated.`); | ||
} | ||
if (loggingConfig.includeExecutionData !== true) { | ||
loggingConfig.includeExecutionData = true; | ||
this.serverless.cli.log(`Warning: Setting includeExecutionData to true for step function ${stepFunction.name} so traces can be generated.`); | ||
} | ||
} | ||
// subscribe step function log group to datadog forwarder regardless of how the log group was created | ||
yield (0, forwarder_1.addStepFunctionLogGroupSubscription)(resources, stepFunction, datadogForwarderArn); | ||
} | ||
} | ||
if (config.mergeStepFunctionAndLambdaTraces || config.propagateTraceContext) { | ||
this.serverless.cli.log(`mergeStepFunctionAndLambdaTraces and propagateTraceContext will be deprecated. Please use propagateUpstreamTrace instead`); | ||
} | ||
if (config.mergeStepFunctionAndLambdaTraces || config.propagateTraceContext || config.propagateUpstreamTrace) { | ||
this.serverless.cli.log(`mergeStepFunctionAndLambdaTraces or propagateUpstreamTrace is true, trying to modify Step Functions' definitions to add trace context.`); | ||
(0, span_link_1.mergeStepFunctionAndLambdaTraces)(resources, this.serverless); | ||
} | ||
} | ||
else { | ||
// Recommend Step Functions instrumentation for customers who do not set enableStepFunctionsTracing to true | ||
try { | ||
(0, step_functions_helper_1.inspectAndRecommendStepFunctionsInstrumentation)(this.serverless); | ||
} | ||
catch (error) { | ||
this.serverless.cli.log(`Error raise when inspecting if there are any uninstrumented Step Functions state machines. Error: ${error}`); | ||
} | ||
} | ||
}); | ||
} | ||
afterDeploy() { | ||
@@ -314,0 +332,0 @@ var _a, _b, _c, _d, _e, _f, _g, _h, _j; |
@@ -48,3 +48,3 @@ import { FunctionDefinition, FunctionDefinitionHandler } from "serverless"; | ||
* | ||
* @param service SLS framework service | ||
* @param service Serverless framework service | ||
* @param handlers Lambda functions to add layers to | ||
@@ -51,0 +51,0 @@ * @param layers layers.json file read into an object |
@@ -103,3 +103,3 @@ "use strict"; | ||
* | ||
* @param service SLS framework service | ||
* @param service Serverless framework service | ||
* @param handlers Lambda functions to add layers to | ||
@@ -106,0 +106,0 @@ * @param layers layers.json file read into an object |
@@ -25,4 +25,4 @@ { | ||
"ruby3.3-arm": "arn:aws-us-gov:lambda:us-gov-west-1:002406178527:layer:Datadog-Ruby3-3-ARM:25", | ||
"extension": "arn:aws-us-gov:lambda:us-gov-west-1:002406178527:layer:Datadog-Extension:76", | ||
"extension-arm": "arn:aws-us-gov:lambda:us-gov-west-1:002406178527:layer:Datadog-Extension-ARM:76", | ||
"extension": "arn:aws-us-gov:lambda:us-gov-west-1:002406178527:layer:Datadog-Extension:77", | ||
"extension-arm": "arn:aws-us-gov:lambda:us-gov-west-1:002406178527:layer:Datadog-Extension-ARM:77", | ||
"dotnet": "arn:aws-us-gov:lambda:us-gov-west-1:002406178527:layer:dd-trace-dotnet:20", | ||
@@ -54,4 +54,4 @@ "dotnet-arm": "arn:aws-us-gov:lambda:us-gov-west-1:002406178527:layer:dd-trace-dotnet-ARM:20", | ||
"ruby3.3-arm": "arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:Datadog-Ruby3-3-ARM:25", | ||
"extension": "arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:Datadog-Extension:76", | ||
"extension-arm": "arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:Datadog-Extension-ARM:76", | ||
"extension": "arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:Datadog-Extension:77", | ||
"extension-arm": "arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:Datadog-Extension-ARM:77", | ||
"dotnet": "arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:dd-trace-dotnet:20", | ||
@@ -58,0 +58,0 @@ "dotnet-arm": "arn:aws-us-gov:lambda:us-gov-east-1:002406178527:layer:dd-trace-dotnet-ARM:20", |
@@ -23,3 +23,3 @@ import { TemplateVariable } from "./monitor-api-requests"; | ||
* @param monitor - the Monitor object that is defined in the serverless.yml file | ||
* @param cloudFormationStackId - the Cloud Formation Stack ID | ||
* @param cloudFormationStackId - the CloudFormation stack ID | ||
* @param service - the Service | ||
@@ -49,3 +49,3 @@ * @param env - the Environment | ||
* @param monitorsAppKey - the Application Key | ||
* @param cloudFormationStackId - the Cloud Formation Stack ID | ||
* @param cloudFormationStackId - the CloudFormation stack ID | ||
* @param service - the Service | ||
@@ -60,3 +60,3 @@ * @param env - the Environment | ||
* @param query - the query string | ||
* @param criticalThreshold = new critical threshold as defined by the customer | ||
* @param criticalThreshold - new critical threshold as defined by the customer | ||
* @returns the query string where the critical threshold is already replaced | ||
@@ -63,0 +63,0 @@ */ |
@@ -17,3 +17,3 @@ "use strict"; | ||
* @param monitor - the Monitor object that is defined in the serverless.yml file | ||
* @param cloudFormationStackId - the Cloud Formation Stack ID | ||
* @param cloudFormationStackId - the CloudFormation stack ID | ||
* @param service - the Service | ||
@@ -137,3 +137,3 @@ * @param env - the Environment | ||
* @param monitorsAppKey - the Application Key | ||
* @param cloudFormationStackId - the Cloud Formation Stack ID | ||
* @param cloudFormationStackId - the CloudFormation stack ID | ||
* @param service - the Service | ||
@@ -188,3 +188,3 @@ * @param env - the Environment | ||
* @param query - the query string | ||
* @param criticalThreshold = new critical threshold as defined by the customer | ||
* @param criticalThreshold - new critical threshold as defined by the customer | ||
* @returns the query string where the critical threshold is already replaced | ||
@@ -191,0 +191,0 @@ */ |
{ | ||
"name": "serverless-plugin-datadog", | ||
"version": "5.90.0", | ||
"version": "5.91.0", | ||
"description": "Serverless plugin to automatically instrument python and node functions with datadog tracing", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -41,3 +41,3 @@  | ||
| `enableDDTracing` | Enable Datadog tracing on the Lambda function. Defaults to `true`. | | ||
| `enableASM` | Enable [Datadog Application Security Management (ASM)][19] on the Lambda function. Requires the Datadog extension to be present (using `addExtension` or manually added) and `enableDDTracing`. Defaults to `false`. | | ||
| `enableASM` | Enable [Datadog App and API Protection (AAP)][19] on the Lambda function. Requires the Datadog extension to be present (using `addExtension` or manually added) and `enableDDTracing`. Defaults to `false`. | | ||
| `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. | | ||
@@ -138,3 +138,3 @@ | `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). | | ||
If you’d like to further configure the parameters for a recommended monitor, you can directly define the parameter values below the serverless monitor ID. Parameters not specified under a recommended monitor will use the default recommended value. The `query` parameter for recommended monitors cannot be directly modified and will default to using the `query` valued as defined above; however, you may change the threshold value in `query` by re-defining it within the `options` parameter. To delete a monitor, remove the monitor from the `serverless.yml` template. For further documentation on how to define monitor parameters, see the [Datadog Monitors API](https://docs.datadoghq.com/api/latest/monitors/#create-a-monitor). | ||
If you'd like to further configure the parameters for a recommended monitor, you can directly define the parameter values below the serverless monitor ID. Parameters not specified under a recommended monitor will use the default recommended value. The `query` parameter for recommended monitors cannot be directly modified and will default to using the `query` valued as defined above; however, you may change the threshold value in `query` by re-defining it within the `options` parameter. To delete a monitor, remove the monitor from the `serverless.yml` template. For further documentation on how to define monitor parameters, see the [Datadog Monitors API](https://docs.datadoghq.com/api/latest/monitors/#create-a-monitor). | ||
@@ -164,3 +164,3 @@ Monitor creation occurs after the function is deployed. In the event that a monitor is unsuccessfully created, the function will still be successfully deployed. | ||
name: "High Error Rate with Modified Warning Threshold" | ||
message: "More than 10% of the function’s invocations were errors in the selected time range. Notify @data.dog@datadoghq.com @slack-serverless-monitors" | ||
message: "More than 10% of the function's invocations were errors in the selected time range. Notify @data.dog@datadoghq.com @slack-serverless-monitors" | ||
tags: ["modified_error_rate", "serverless", "error_rate"] | ||
@@ -167,0 +167,0 @@ require_full_window: true |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
349550
0.31%3672
0.49%