@datadog/datadog-ci 0.17.10 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +2 -0
- package/README.md +9 -2
- package/dist/{commands/dependencies/index.d.ts → cli.d.ts} +0 -0
- package/dist/cli.js +34 -0
- package/dist/commands/{dsyms/index.d.ts → dependencies/cli.d.ts} +0 -0
- package/dist/commands/dependencies/{index.js → cli.js} +0 -0
- package/dist/commands/dependencies/upload.d.ts +1 -1
- package/dist/commands/{git-metadata/index.d.ts → dsyms/cli.d.ts} +0 -0
- package/dist/commands/dsyms/{index.js → cli.js} +0 -0
- package/dist/commands/dsyms/upload.d.ts +1 -1
- package/dist/commands/{junit/index.d.ts → git-metadata/cli.d.ts} +0 -0
- package/dist/commands/git-metadata/{index.js → cli.js} +0 -0
- package/dist/commands/git-metadata/upload.d.ts +1 -1
- package/dist/commands/git-metadata/upload.js +6 -1
- package/dist/commands/{lambda/index.d.ts → junit/cli.d.ts} +0 -0
- package/dist/commands/junit/{index.js → cli.js} +0 -0
- package/dist/commands/junit/upload.d.ts +1 -1
- package/dist/commands/junit/upload.js +1 -1
- package/dist/commands/lambda/__tests__/fixtures.d.ts +5 -1
- package/dist/commands/lambda/__tests__/fixtures.js +13 -2
- package/dist/commands/lambda/__tests__/functions/commons.test.js +281 -2
- package/dist/commands/lambda/__tests__/functions/instrument.test.js +109 -54
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +113 -7
- package/dist/commands/lambda/__tests__/instrument.test.js +760 -111
- package/dist/commands/{sourcemaps/index.d.ts → lambda/__tests__/prompt.test.d.ts} +0 -0
- package/dist/commands/lambda/__tests__/prompt.test.js +216 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.js +380 -17
- package/dist/commands/{trace/index.d.ts → lambda/cli.d.ts} +0 -0
- package/dist/commands/lambda/{index.js → cli.js} +0 -0
- package/dist/commands/lambda/constants.d.ts +47 -16
- package/dist/commands/lambda/constants.js +72 -17
- package/dist/commands/lambda/functions/commons.d.ts +38 -3
- package/dist/commands/lambda/functions/commons.js +179 -9
- package/dist/commands/lambda/functions/instrument.d.ts +5 -11
- package/dist/commands/lambda/functions/instrument.js +89 -63
- package/dist/commands/lambda/functions/uninstrument.d.ts +3 -2
- package/dist/commands/lambda/functions/uninstrument.js +41 -15
- package/dist/commands/lambda/instrument.d.ts +2 -1
- package/dist/commands/lambda/instrument.js +115 -58
- package/dist/commands/lambda/interfaces.d.ts +4 -1
- package/dist/commands/lambda/loggroup.js +3 -1
- package/dist/commands/lambda/prompt.d.ts +9 -0
- package/dist/commands/lambda/prompt.js +187 -0
- package/dist/commands/lambda/uninstrument.d.ts +2 -0
- package/dist/commands/lambda/uninstrument.js +107 -30
- package/dist/commands/sourcemaps/cli.d.ts +1 -0
- package/dist/commands/sourcemaps/{index.js → cli.js} +0 -0
- package/dist/commands/sourcemaps/upload.d.ts +1 -1
- package/dist/commands/synthetics/__tests__/cli.test.js +36 -13
- package/dist/commands/synthetics/__tests__/fixtures.js +1 -0
- package/dist/commands/synthetics/__tests__/run-test.test.js +48 -2
- package/dist/commands/synthetics/__tests__/utils.test.js +12 -0
- package/dist/commands/synthetics/__tests__/websocket.test.js +3 -3
- package/dist/commands/synthetics/cli.d.ts +1 -26
- package/dist/commands/synthetics/cli.js +2 -227
- package/dist/commands/synthetics/command.d.ts +27 -0
- package/dist/commands/synthetics/command.js +236 -0
- package/dist/commands/synthetics/index.d.ts +5 -1
- package/dist/commands/synthetics/index.js +31 -2
- package/dist/commands/synthetics/interfaces.d.ts +9 -3
- package/dist/commands/synthetics/interfaces.js +7 -3
- package/dist/commands/synthetics/reporters/default.js +5 -1
- package/dist/commands/synthetics/run-test.d.ts +2 -0
- package/dist/commands/synthetics/run-test.js +3 -1
- package/dist/commands/synthetics/utils.d.ts +3 -0
- package/dist/commands/synthetics/utils.js +37 -13
- package/dist/commands/trace/api.js +1 -1
- package/dist/commands/trace/cli.d.ts +1 -0
- package/dist/commands/trace/{index.js → cli.js} +0 -0
- package/dist/commands/trace/trace.d.ts +1 -1
- package/dist/helpers/__tests__/ci.test.js +71 -24
- package/dist/helpers/__tests__/user-provided-git.test.js +69 -27
- package/dist/helpers/ci.js +1 -1
- package/dist/helpers/git.js +1 -1
- package/dist/helpers/user-provided-git.d.ts +2 -1
- package/dist/helpers/user-provided-git.js +18 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +23 -31
- package/package.json +9 -7
|
@@ -9,33 +9,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.calculateUpdateRequest = exports.
|
|
12
|
+
exports.calculateUpdateRequest = exports.getInstrumentedFunctionConfigsFromRegEx = exports.getInstrumentedFunctionConfig = exports.getInstrumentedFunctionConfigs = void 0;
|
|
13
13
|
const constants_1 = require("../constants");
|
|
14
14
|
const loggroup_1 = require("../loggroup");
|
|
15
15
|
const tags_1 = require("../tags");
|
|
16
16
|
const commons_1 = require("./commons");
|
|
17
|
-
const
|
|
17
|
+
const getInstrumentedFunctionConfigs = (lambda, cloudWatch, region, functionARNs, settings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
const lambdaFunctionConfigs = yield commons_1.getLambdaFunctionConfigs(lambda, functionARNs);
|
|
19
19
|
const configs = [];
|
|
20
20
|
for (const config of lambdaFunctionConfigs) {
|
|
21
|
-
const functionConfig = yield exports.
|
|
21
|
+
const functionConfig = yield exports.getInstrumentedFunctionConfig(lambda, cloudWatch, config, region, settings);
|
|
22
22
|
configs.push(functionConfig);
|
|
23
23
|
}
|
|
24
24
|
return configs;
|
|
25
25
|
});
|
|
26
|
-
exports.
|
|
27
|
-
const
|
|
26
|
+
exports.getInstrumentedFunctionConfigs = getInstrumentedFunctionConfigs;
|
|
27
|
+
const getInstrumentedFunctionConfig = (lambda, cloudWatch, config, region, settings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
const functionARN = config.FunctionArn;
|
|
29
29
|
const runtime = config.Runtime;
|
|
30
30
|
if (!commons_1.isSupportedRuntime(runtime)) {
|
|
31
31
|
throw Error(`Can't instrument ${functionARN}, runtime ${runtime} not supported`);
|
|
32
32
|
}
|
|
33
33
|
yield commons_1.isLambdaActive(lambda, config, functionARN);
|
|
34
|
-
const updateRequest = exports.calculateUpdateRequest(config, settings, region, runtime);
|
|
34
|
+
const updateRequest = yield exports.calculateUpdateRequest(config, settings, region, runtime);
|
|
35
35
|
let logGroupConfiguration;
|
|
36
36
|
if (settings.forwarderARN !== undefined) {
|
|
37
|
-
const
|
|
38
|
-
logGroupConfiguration = yield loggroup_1.calculateLogGroupUpdateRequest(cloudWatch,
|
|
37
|
+
const logGroupName = `/aws/lambda/${config.FunctionName}`;
|
|
38
|
+
logGroupConfiguration = yield loggroup_1.calculateLogGroupUpdateRequest(cloudWatch, logGroupName, settings.forwarderARN);
|
|
39
39
|
}
|
|
40
40
|
const tagConfiguration = yield tags_1.calculateTagUpdateRequest(lambda, functionARN);
|
|
41
41
|
return {
|
|
@@ -46,41 +46,19 @@ const getFunctionConfig = (lambda, cloudWatch, config, region, settings) => __aw
|
|
|
46
46
|
updateRequest,
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
|
-
exports.
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const regEx = new RegExp(pattern);
|
|
53
|
-
const matchedFunctions = [];
|
|
54
|
-
let retryCount = 0;
|
|
55
|
-
let listFunctionsResponse;
|
|
56
|
-
let nextMarker;
|
|
57
|
-
while (true) {
|
|
58
|
-
try {
|
|
59
|
-
listFunctionsResponse = yield lambda.listFunctions({ Marker: nextMarker }).promise();
|
|
60
|
-
(_a = listFunctionsResponse.Functions) === null || _a === void 0 ? void 0 : _a.map((fn) => { var _a; return ((_a = fn.FunctionName) === null || _a === void 0 ? void 0 : _a.match(regEx)) && matchedFunctions.push(fn); });
|
|
61
|
-
nextMarker = listFunctionsResponse.NextMarker;
|
|
62
|
-
if (!nextMarker) {
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
retryCount = 0;
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
retryCount++;
|
|
69
|
-
if (retryCount > constants_1.LIST_FUNCTIONS_MAX_RETRY_COUNT) {
|
|
70
|
-
throw Error('Max retry count exceeded.');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
49
|
+
exports.getInstrumentedFunctionConfig = getInstrumentedFunctionConfig;
|
|
50
|
+
const getInstrumentedFunctionConfigsFromRegEx = (lambda, cloudWatch, region, pattern, settings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
const matchedFunctions = yield commons_1.getLambdaFunctionConfigsFromRegex(lambda, pattern);
|
|
74
52
|
const functionsToUpdate = [];
|
|
75
53
|
for (const config of matchedFunctions) {
|
|
76
|
-
const functionConfig = yield exports.
|
|
54
|
+
const functionConfig = yield exports.getInstrumentedFunctionConfig(lambda, cloudWatch, config, region, settings);
|
|
77
55
|
functionsToUpdate.push(functionConfig);
|
|
78
56
|
}
|
|
79
57
|
return functionsToUpdate;
|
|
80
58
|
});
|
|
81
|
-
exports.
|
|
82
|
-
const calculateUpdateRequest = (config, settings, region, runtime) => {
|
|
83
|
-
var _a, _b, _c;
|
|
59
|
+
exports.getInstrumentedFunctionConfigsFromRegEx = getInstrumentedFunctionConfigsFromRegEx;
|
|
60
|
+
const calculateUpdateRequest = (config, settings, region, runtime) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
var _a, _b, _c, _d, _e;
|
|
84
62
|
const oldEnvVars = Object.assign({}, (_a = config.Environment) === null || _a === void 0 ? void 0 : _a.Variables);
|
|
85
63
|
const changedEnvVars = {};
|
|
86
64
|
const functionARN = config.FunctionArn;
|
|
@@ -95,16 +73,41 @@ const calculateUpdateRequest = (config, settings, region, runtime) => {
|
|
|
95
73
|
FunctionName: functionARN,
|
|
96
74
|
};
|
|
97
75
|
let needsUpdate = false;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
76
|
+
if (constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.JAVA ||
|
|
77
|
+
constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.CUSTOM ||
|
|
78
|
+
constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.RUBY) {
|
|
79
|
+
if (settings.layerVersion !== undefined) {
|
|
80
|
+
throw new Error(`Only the --extension-version argument should be set for the ${runtime} runtime. Please remove the --layer-version argument from the instrument command.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// We don't support ARM Architecture for .NET at this time. Abort instrumentation if the combination is detected.
|
|
84
|
+
if (constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.DOTNET) {
|
|
85
|
+
if ((_b = config.Architectures) === null || _b === void 0 ? void 0 : _b.includes(constants_1.ARM64_ARCHITECTURE)) {
|
|
86
|
+
throw new Error('Instrumenting arm64 architecture is not currently supported for .NET. Please only instrument .NET functions using x86_64 architecture.');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Update Python Handler
|
|
90
|
+
if (constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.PYTHON) {
|
|
91
|
+
const expectedHandler = constants_1.PYTHON_HANDLER_LOCATION;
|
|
92
|
+
if (config.Handler !== expectedHandler) {
|
|
93
|
+
needsUpdate = true;
|
|
94
|
+
updateRequest.Handler = constants_1.PYTHON_HANDLER_LOCATION;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Update Node Handler
|
|
98
|
+
if (constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.NODE) {
|
|
99
|
+
const expectedHandler = constants_1.NODE_HANDLER_LOCATION;
|
|
100
|
+
if (config.Handler !== expectedHandler) {
|
|
101
|
+
needsUpdate = true;
|
|
102
|
+
updateRequest.Handler = constants_1.NODE_HANDLER_LOCATION;
|
|
103
|
+
}
|
|
103
104
|
}
|
|
104
105
|
// Update Env Vars
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
if (constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.PYTHON || constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.NODE) {
|
|
107
|
+
if (oldEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR] === undefined) {
|
|
108
|
+
needsUpdate = true;
|
|
109
|
+
changedEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR] = (_c = config.Handler) !== null && _c !== void 0 ? _c : '';
|
|
110
|
+
}
|
|
108
111
|
}
|
|
109
112
|
// KMS > Secrets Manager > API Key
|
|
110
113
|
if (apiKmsKey !== undefined && oldEnvVars[constants_1.KMS_API_KEY_ENV_VAR] !== apiKmsKey) {
|
|
@@ -125,13 +128,12 @@ const calculateUpdateRequest = (config, settings, region, runtime) => {
|
|
|
125
128
|
changedEnvVars[constants_1.API_KEY_ENV_VAR] = apiKey;
|
|
126
129
|
}
|
|
127
130
|
if (site !== undefined && oldEnvVars[constants_1.SITE_ENV_VAR] !== site) {
|
|
128
|
-
|
|
129
|
-
if (siteList.includes(site.toLowerCase())) {
|
|
131
|
+
if (constants_1.SITES.includes(site.toLowerCase())) {
|
|
130
132
|
needsUpdate = true;
|
|
131
133
|
changedEnvVars[constants_1.SITE_ENV_VAR] = site;
|
|
132
134
|
}
|
|
133
135
|
else {
|
|
134
|
-
throw new Error('Warning: Invalid site URL. Must be either datadoghq.com, datadoghq.eu, us3.datadoghq.com, or ddog-gov.com.');
|
|
136
|
+
throw new Error('Warning: Invalid site URL. Must be either datadoghq.com, datadoghq.eu, us3.datadoghq.com, us5.datadoghq.com, or ddog-gov.com.');
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
if (site === undefined && oldEnvVars[constants_1.SITE_ENV_VAR] === undefined) {
|
|
@@ -139,20 +141,28 @@ const calculateUpdateRequest = (config, settings, region, runtime) => {
|
|
|
139
141
|
changedEnvVars[constants_1.SITE_ENV_VAR] = 'datadoghq.com';
|
|
140
142
|
}
|
|
141
143
|
const environmentVarsTupleArray = [
|
|
144
|
+
['captureLambdaPayload', constants_1.CAPTURE_LAMBDA_PAYLOAD_ENV_VAR],
|
|
142
145
|
['environment', constants_1.ENVIRONMENT_ENV_VAR],
|
|
143
146
|
['extraTags', constants_1.EXTRA_TAGS_ENV_VAR],
|
|
144
|
-
['flushMetricsToLogs', constants_1.FLUSH_TO_LOG_ENV_VAR],
|
|
145
147
|
['mergeXrayTraces', constants_1.MERGE_XRAY_TRACES_ENV_VAR],
|
|
146
148
|
['service', constants_1.SERVICE_ENV_VAR],
|
|
147
149
|
['tracingEnabled', constants_1.TRACE_ENABLED_ENV_VAR],
|
|
148
150
|
['version', constants_1.VERSION_ENV_VAR],
|
|
149
151
|
];
|
|
150
152
|
for (const [key, environmentVar] of environmentVarsTupleArray) {
|
|
151
|
-
if (settings[key] !== undefined && oldEnvVars[environmentVar] !== ((
|
|
153
|
+
if (settings[key] !== undefined && oldEnvVars[environmentVar] !== ((_d = settings[key]) === null || _d === void 0 ? void 0 : _d.toString())) {
|
|
152
154
|
needsUpdate = true;
|
|
153
155
|
changedEnvVars[environmentVar] = settings[key].toString();
|
|
154
156
|
}
|
|
155
157
|
}
|
|
158
|
+
// Skip adding DD_FLUSH_TO_LOGS when using Extension
|
|
159
|
+
const isUsingExtension = settings.extensionVersion !== undefined;
|
|
160
|
+
if (!isUsingExtension &&
|
|
161
|
+
settings.flushMetricsToLogs !== undefined &&
|
|
162
|
+
oldEnvVars[constants_1.FLUSH_TO_LOG_ENV_VAR] !== ((_e = settings.flushMetricsToLogs) === null || _e === void 0 ? void 0 : _e.toString())) {
|
|
163
|
+
needsUpdate = true;
|
|
164
|
+
changedEnvVars[constants_1.FLUSH_TO_LOG_ENV_VAR] = settings.flushMetricsToLogs.toString();
|
|
165
|
+
}
|
|
156
166
|
const newEnvVars = Object.assign(Object.assign({}, oldEnvVars), changedEnvVars);
|
|
157
167
|
if (newEnvVars[constants_1.LOG_LEVEL_ENV_VAR] !== settings.logLevel) {
|
|
158
168
|
needsUpdate = true;
|
|
@@ -163,25 +173,41 @@ const calculateUpdateRequest = (config, settings, region, runtime) => {
|
|
|
163
173
|
delete newEnvVars[constants_1.LOG_LEVEL_ENV_VAR];
|
|
164
174
|
}
|
|
165
175
|
}
|
|
176
|
+
if (runtime === constants_1.DOTNET_RUNTIME) {
|
|
177
|
+
needsUpdate = true;
|
|
178
|
+
newEnvVars[constants_1.ENABLE_PROFILING_ENV_VAR] = constants_1.CORECLR_ENABLE_PROFILING;
|
|
179
|
+
newEnvVars[constants_1.PROFILER_ENV_VAR] = constants_1.CORECLR_PROFILER;
|
|
180
|
+
newEnvVars[constants_1.PROFILER_PATH_ENV_VAR] = constants_1.CORECLR_PROFILER_PATH;
|
|
181
|
+
newEnvVars[constants_1.DOTNET_TRACER_HOME_ENV_VAR] = constants_1.DD_DOTNET_TRACER_HOME;
|
|
182
|
+
}
|
|
166
183
|
updateRequest.Environment = {
|
|
167
184
|
Variables: newEnvVars,
|
|
168
185
|
};
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
186
|
+
let layerARNs = commons_1.getLayers(config);
|
|
187
|
+
const originalLayerARNs = layerARNs;
|
|
188
|
+
let needsLayerUpdate = false;
|
|
189
|
+
if (commons_1.isLayerRuntime(runtime)) {
|
|
190
|
+
const lambdaLibraryLayerArn = commons_1.getLayerArn(config, config.Runtime, region, settings);
|
|
191
|
+
const lambdaLibraryLayerName = constants_1.LAYER_LOOKUP[runtime];
|
|
192
|
+
let fullLambdaLibraryLayerARN;
|
|
193
|
+
if (settings.layerVersion !== undefined || settings.interactive) {
|
|
194
|
+
let layerVersion = settings.layerVersion;
|
|
195
|
+
if (settings.interactive && !settings.layerVersion) {
|
|
196
|
+
layerVersion = yield commons_1.findLatestLayerVersion(config.Runtime, region);
|
|
197
|
+
}
|
|
198
|
+
fullLambdaLibraryLayerARN = `${lambdaLibraryLayerArn}:${layerVersion}`;
|
|
199
|
+
}
|
|
200
|
+
layerARNs = commons_1.addLayerArn(fullLambdaLibraryLayerARN, lambdaLibraryLayerName, layerARNs);
|
|
175
201
|
}
|
|
176
202
|
const lambdaExtensionLayerArn = commons_1.getLayerArn(config, constants_1.EXTENSION_LAYER_KEY, region, settings);
|
|
177
203
|
let fullExtensionLayerARN;
|
|
178
|
-
if (settings.extensionVersion !== undefined) {
|
|
179
|
-
|
|
204
|
+
if (settings.extensionVersion !== undefined || settings.interactive) {
|
|
205
|
+
let extensionVersion = settings.extensionVersion;
|
|
206
|
+
if (settings.interactive && !settings.extensionVersion) {
|
|
207
|
+
extensionVersion = yield commons_1.findLatestLayerVersion(constants_1.EXTENSION_LAYER_KEY, region);
|
|
208
|
+
}
|
|
209
|
+
fullExtensionLayerARN = `${lambdaExtensionLayerArn}:${extensionVersion}`;
|
|
180
210
|
}
|
|
181
|
-
let layerARNs = commons_1.getLayers(config);
|
|
182
|
-
const originalLayerARNs = layerARNs;
|
|
183
|
-
let needsLayerUpdate = false;
|
|
184
|
-
layerARNs = commons_1.addLayerArn(fullLambdaLibraryLayerARN, lambraLibraryLayerName, layerARNs);
|
|
185
211
|
layerARNs = commons_1.addLayerArn(fullExtensionLayerARN, constants_1.DD_LAMBDA_EXTENSION_LAYER_NAME, layerARNs);
|
|
186
212
|
if (originalLayerARNs.sort().join(',') !== layerARNs.sort().join(',')) {
|
|
187
213
|
needsLayerUpdate = true;
|
|
@@ -199,5 +225,5 @@ const calculateUpdateRequest = (config, settings, region, runtime) => {
|
|
|
199
225
|
}
|
|
200
226
|
});
|
|
201
227
|
return needsUpdate ? updateRequest : undefined;
|
|
202
|
-
};
|
|
228
|
+
});
|
|
203
229
|
exports.calculateUpdateRequest = calculateUpdateRequest;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CloudWatchLogs, Lambda } from 'aws-sdk';
|
|
2
2
|
import { Runtime } from '../constants';
|
|
3
3
|
import { FunctionConfiguration } from '../interfaces';
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
4
|
+
export declare const getUninstrumentedFunctionConfigs: (lambda: Lambda, cloudWatch: CloudWatchLogs, functionARNs: string[], forwarderARN: string | undefined) => Promise<FunctionConfiguration[]>;
|
|
5
|
+
export declare const getUninstrumentedFunctionConfig: (lambda: Lambda, cloudWatch: CloudWatchLogs, config: Lambda.FunctionConfiguration, forwarderARN: string | undefined) => Promise<FunctionConfiguration>;
|
|
6
|
+
export declare const getUninstrumentedFunctionConfigsFromRegEx: (lambda: Lambda, cloudWatch: CloudWatchLogs, pattern: string, forwarderArn: string | undefined) => Promise<FunctionConfiguration[]>;
|
|
6
7
|
export declare const calculateUpdateRequest: (config: Lambda.FunctionConfiguration, runtime: Runtime) => Lambda.UpdateFunctionConfigurationRequest | undefined;
|
|
@@ -9,22 +9,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.calculateUpdateRequest = exports.
|
|
12
|
+
exports.calculateUpdateRequest = exports.getUninstrumentedFunctionConfigsFromRegEx = exports.getUninstrumentedFunctionConfig = exports.getUninstrumentedFunctionConfigs = void 0;
|
|
13
13
|
const constants_1 = require("../constants");
|
|
14
14
|
const loggroup_1 = require("../loggroup");
|
|
15
15
|
const tags_1 = require("../tags");
|
|
16
16
|
const commons_1 = require("./commons");
|
|
17
|
-
const
|
|
17
|
+
const getUninstrumentedFunctionConfigs = (lambda, cloudWatch, functionARNs, forwarderARN) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
const lambdaFunctionConfigs = yield commons_1.getLambdaFunctionConfigs(lambda, functionARNs);
|
|
19
19
|
const configs = [];
|
|
20
20
|
for (const config of lambdaFunctionConfigs) {
|
|
21
|
-
const functionConfig = yield exports.
|
|
21
|
+
const functionConfig = yield exports.getUninstrumentedFunctionConfig(lambda, cloudWatch, config, forwarderARN);
|
|
22
22
|
configs.push(functionConfig);
|
|
23
23
|
}
|
|
24
24
|
return configs;
|
|
25
25
|
});
|
|
26
|
-
exports.
|
|
27
|
-
const
|
|
26
|
+
exports.getUninstrumentedFunctionConfigs = getUninstrumentedFunctionConfigs;
|
|
27
|
+
const getUninstrumentedFunctionConfig = (lambda, cloudWatch, config, forwarderARN) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
const functionARN = config.FunctionArn;
|
|
29
29
|
const runtime = config.Runtime;
|
|
30
30
|
if (!commons_1.isSupportedRuntime(runtime)) {
|
|
@@ -33,8 +33,8 @@ const getFunctionConfig = (lambda, cloudWatch, config, forwarderARN) => __awaite
|
|
|
33
33
|
const updateRequest = exports.calculateUpdateRequest(config, runtime);
|
|
34
34
|
let logGroupConfiguration;
|
|
35
35
|
if (forwarderARN) {
|
|
36
|
-
const
|
|
37
|
-
logGroupConfiguration = yield loggroup_1.calculateLogGroupRemoveRequest(cloudWatch,
|
|
36
|
+
const logGroupName = `/aws/lambda/${config.FunctionName}`;
|
|
37
|
+
logGroupConfiguration = yield loggroup_1.calculateLogGroupRemoveRequest(cloudWatch, logGroupName, forwarderARN);
|
|
38
38
|
}
|
|
39
39
|
const tagConfiguration = yield tags_1.calculateTagRemoveRequest(lambda, functionARN);
|
|
40
40
|
return {
|
|
@@ -45,7 +45,17 @@ const getFunctionConfig = (lambda, cloudWatch, config, forwarderARN) => __awaite
|
|
|
45
45
|
updateRequest,
|
|
46
46
|
};
|
|
47
47
|
});
|
|
48
|
-
exports.
|
|
48
|
+
exports.getUninstrumentedFunctionConfig = getUninstrumentedFunctionConfig;
|
|
49
|
+
const getUninstrumentedFunctionConfigsFromRegEx = (lambda, cloudWatch, pattern, forwarderArn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const matchedFunctions = yield commons_1.getLambdaFunctionConfigsFromRegex(lambda, pattern);
|
|
51
|
+
const functionsToUpdate = [];
|
|
52
|
+
for (const config of matchedFunctions) {
|
|
53
|
+
const functionConfig = yield exports.getUninstrumentedFunctionConfig(lambda, cloudWatch, config, forwarderArn);
|
|
54
|
+
functionsToUpdate.push(functionConfig);
|
|
55
|
+
}
|
|
56
|
+
return functionsToUpdate;
|
|
57
|
+
});
|
|
58
|
+
exports.getUninstrumentedFunctionConfigsFromRegEx = getUninstrumentedFunctionConfigsFromRegEx;
|
|
49
59
|
const calculateUpdateRequest = (config, runtime) => {
|
|
50
60
|
var _a, _b;
|
|
51
61
|
const oldEnvVars = Object.assign({}, (_a = config.Environment) === null || _a === void 0 ? void 0 : _a.Variables);
|
|
@@ -57,12 +67,23 @@ const calculateUpdateRequest = (config, runtime) => {
|
|
|
57
67
|
FunctionName: functionARN,
|
|
58
68
|
};
|
|
59
69
|
let needsUpdate = false;
|
|
60
|
-
// Remove Handler
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
// Remove Handler for Python
|
|
71
|
+
if (constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.PYTHON) {
|
|
72
|
+
const expectedHandler = constants_1.PYTHON_HANDLER_LOCATION;
|
|
73
|
+
if (config.Handler === expectedHandler) {
|
|
74
|
+
needsUpdate = true;
|
|
75
|
+
updateRequest.Handler = oldEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR];
|
|
76
|
+
delete oldEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Remove Handler for Node
|
|
80
|
+
if (constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RuntimeType.NODE) {
|
|
81
|
+
const expectedHandler = constants_1.NODE_HANDLER_LOCATION;
|
|
82
|
+
if (config.Handler === expectedHandler) {
|
|
83
|
+
needsUpdate = true;
|
|
84
|
+
updateRequest.Handler = oldEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR];
|
|
85
|
+
delete oldEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR];
|
|
86
|
+
}
|
|
66
87
|
}
|
|
67
88
|
/**
|
|
68
89
|
* Array used to remove environment vars used in
|
|
@@ -73,6 +94,7 @@ const calculateUpdateRequest = (config, runtime) => {
|
|
|
73
94
|
constants_1.API_KEY_SECRET_ARN_ENV_VAR,
|
|
74
95
|
constants_1.KMS_API_KEY_ENV_VAR,
|
|
75
96
|
constants_1.SITE_ENV_VAR,
|
|
97
|
+
constants_1.CAPTURE_LAMBDA_PAYLOAD_ENV_VAR,
|
|
76
98
|
constants_1.ENVIRONMENT_ENV_VAR,
|
|
77
99
|
constants_1.EXTRA_TAGS_ENV_VAR,
|
|
78
100
|
constants_1.FLUSH_TO_LOG_ENV_VAR,
|
|
@@ -81,6 +103,10 @@ const calculateUpdateRequest = (config, runtime) => {
|
|
|
81
103
|
constants_1.SERVICE_ENV_VAR,
|
|
82
104
|
constants_1.TRACE_ENABLED_ENV_VAR,
|
|
83
105
|
constants_1.VERSION_ENV_VAR,
|
|
106
|
+
constants_1.ENABLE_PROFILING_ENV_VAR,
|
|
107
|
+
constants_1.PROFILER_ENV_VAR,
|
|
108
|
+
constants_1.PROFILER_PATH_ENV_VAR,
|
|
109
|
+
constants_1.DOTNET_TRACER_HOME_ENV_VAR,
|
|
84
110
|
];
|
|
85
111
|
// Remove Environment Variables
|
|
86
112
|
for (const environmentVar of environmentVarsArray) {
|
|
@@ -94,7 +120,7 @@ const calculateUpdateRequest = (config, runtime) => {
|
|
|
94
120
|
};
|
|
95
121
|
// Remove Layers
|
|
96
122
|
let needsLayerRemoval = false;
|
|
97
|
-
const lambdaLibraryLayerName = constants_1.
|
|
123
|
+
const lambdaLibraryLayerName = constants_1.LAYER_LOOKUP[runtime];
|
|
98
124
|
const originalLayerARNs = commons_1.getLayers(config);
|
|
99
125
|
const layerARNs = ((_b = config.Layers) !== null && _b !== void 0 ? _b : [])
|
|
100
126
|
.filter((layer) => { var _a, _b; return !((_a = layer.Arn) === null || _a === void 0 ? void 0 : _a.includes(lambdaLibraryLayerName)) && !((_b = layer.Arn) === null || _b === void 0 ? void 0 : _b.includes(constants_1.DD_LAMBDA_EXTENSION_LAYER_NAME)); })
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from 'clipanion';
|
|
2
2
|
export declare class InstrumentCommand extends Command {
|
|
3
|
+
private captureLambdaPayload?;
|
|
3
4
|
private config;
|
|
4
5
|
private configPath?;
|
|
5
6
|
private dryRun;
|
|
@@ -9,6 +10,7 @@ export declare class InstrumentCommand extends Command {
|
|
|
9
10
|
private flushMetricsToLogs?;
|
|
10
11
|
private forwarder?;
|
|
11
12
|
private functions;
|
|
13
|
+
private interactive;
|
|
12
14
|
private layerAWSAccount?;
|
|
13
15
|
private layerVersion?;
|
|
14
16
|
private logLevel?;
|
|
@@ -20,7 +22,6 @@ export declare class InstrumentCommand extends Command {
|
|
|
20
22
|
private tracing?;
|
|
21
23
|
private version?;
|
|
22
24
|
execute(): Promise<1 | 0>;
|
|
23
|
-
private convertStringBooleanToBoolean;
|
|
24
25
|
private getCurrentGitStatus;
|
|
25
26
|
private getGitDataAndUpload;
|
|
26
27
|
private getSettings;
|