@datadog/datadog-ci 0.17.13 → 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.
@@ -28,7 +28,7 @@ describe('commons', () => {
28
28
  'arn:aws:lambda:sa-east-1:464622532012:layer:Datadog-Extension:10',
29
29
  ];
30
30
  const region = 'sa-east-1';
31
- const lambdaLibraryLayerName = constants_1.RUNTIME_LAYER_LOOKUP[runtime];
31
+ const lambdaLibraryLayerName = constants_1.LAYER_LOOKUP[runtime];
32
32
  const fullLambdaLibraryLayerArn = commons_1.getLayerArn(config, config.Runtime, region) + ':49';
33
33
  const fullExtensionLayerArn = commons_1.getLayerArn(config, constants_1.EXTENSION_LAYER_KEY, region) + ':11';
34
34
  layerARNs = commons_1.addLayerArn(fullLambdaLibraryLayerArn, lambdaLibraryLayerName, layerARNs);
@@ -49,7 +49,7 @@ describe('commons', () => {
49
49
  'arn:aws:lambda:sa-east-1:464622532012:layer:Datadog-Extension:11',
50
50
  ];
51
51
  const region = 'sa-east-1';
52
- const lambdaLibraryLayerName = constants_1.RUNTIME_LAYER_LOOKUP[runtime];
52
+ const lambdaLibraryLayerName = constants_1.LAYER_LOOKUP[runtime];
53
53
  const fullLambdaLibraryLayerArn = commons_1.getLayerArn(config, config.Runtime, region) + ':49';
54
54
  const fullExtensionLayerArn = commons_1.getLayerArn(config, constants_1.EXTENSION_LAYER_KEY, region) + ':11';
55
55
  layerARNs = commons_1.addLayerArn(fullLambdaLibraryLayerArn, lambdaLibraryLayerName, layerARNs);
@@ -568,4 +568,48 @@ describe('commons', () => {
568
568
  });
569
569
  }));
570
570
  });
571
+ describe('Correctly handles multiple runtimes', () => {
572
+ test('returns true if all runtimes are uniform', () => __awaiter(void 0, void 0, void 0, function* () {
573
+ const configs = [
574
+ {
575
+ functionARN: 'arn:aws:lambda:us-east-1:000000000000:function:func1',
576
+ lambdaConfig: {
577
+ FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:func1',
578
+ Handler: 'index.handler',
579
+ Runtime: 'nodejs14.x',
580
+ },
581
+ },
582
+ {
583
+ functionARN: 'arn:aws:lambda:us-east-1:000000000000:function:func2',
584
+ lambdaConfig: {
585
+ FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:func2',
586
+ Handler: 'index.handler',
587
+ Runtime: 'nodejs12.x',
588
+ },
589
+ },
590
+ ];
591
+ expect(commons_1.checkRuntimeTypesAreUniform(configs)).toBe(true);
592
+ }));
593
+ test('returns false if runtimes are not uniform', () => __awaiter(void 0, void 0, void 0, function* () {
594
+ const configs = [
595
+ {
596
+ functionARN: 'arn:aws:lambda:us-east-1:000000000000:function:func1',
597
+ lambdaConfig: {
598
+ FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:func1',
599
+ Handler: 'index.handler',
600
+ Runtime: 'nodejs14.x',
601
+ },
602
+ },
603
+ {
604
+ functionARN: 'arn:aws:lambda:us-east-1:000000000000:function:func2',
605
+ lambdaConfig: {
606
+ FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:func2',
607
+ Handler: 'index.handler',
608
+ Runtime: 'python3.9',
609
+ },
610
+ },
611
+ ];
612
+ expect(commons_1.checkRuntimeTypesAreUniform(configs)).toBe(false);
613
+ }));
614
+ });
571
615
  });
@@ -235,6 +235,40 @@ describe('uninstrument', () => {
235
235
  }
236
236
  `);
237
237
  }));
238
+ test('correctly removes .NET env vars', () => __awaiter(void 0, void 0, void 0, function* () {
239
+ const lambda = fixtures_1.makeMockLambda({
240
+ 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument': {
241
+ Environment: {
242
+ Variables: {
243
+ [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'false',
244
+ [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
245
+ [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
246
+ [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
247
+ [constants_1.TRACE_ENABLED_ENV_VAR]: 'false',
248
+ [constants_1.SERVICE_ENV_VAR]: 'middletier',
249
+ [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
250
+ [constants_1.VERSION_ENV_VAR]: '0.2',
251
+ [constants_1.ENABLE_PROFILING_ENV_VAR]: '1',
252
+ [constants_1.PROFILER_ENV_VAR]: '{846F5F1C-F9AE-4B07-969E-05C26BC060D8}',
253
+ [constants_1.PROFILER_PATH_ENV_VAR]: '/opt/datadog/Datadog.Trace.ClrProfiler.Native.so',
254
+ [constants_1.DOTNET_TRACER_HOME_ENV_VAR]: '/opt/datadog',
255
+ },
256
+ },
257
+ FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument',
258
+ Runtime: 'dotnetcore3.1',
259
+ },
260
+ });
261
+ const cloudWatch = fixtures_1.makeMockCloudWatchLogs({});
262
+ const result = yield uninstrument_1.getUninstrumentedFunctionConfigs(lambda, cloudWatch, ['arn:aws:lambda:us-east-1:000000000000:function:uninstrument'], undefined);
263
+ expect(result[0].updateRequest).toMatchInlineSnapshot(`
264
+ Object {
265
+ "Environment": Object {
266
+ "Variables": Object {},
267
+ },
268
+ "FunctionName": "arn:aws:lambda:us-east-1:000000000000:function:uninstrument",
269
+ }
270
+ `);
271
+ }));
238
272
  });
239
273
  describe('getUninstrumentedFunctionConfig', () => {
240
274
  const OLD_ENV = process.env;
@@ -268,6 +268,75 @@ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
268
268
  \\"dd_sls_ci\\": \\"v${version}\\"
269
269
  }
270
270
  "
271
+ `);
272
+ }));
273
+ test('prints dry run data for lambda .NET layer', () => __awaiter(void 0, void 0, void 0, function* () {
274
+ ;
275
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
276
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
277
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
278
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
279
+ Runtime: 'dotnetcore3.1',
280
+ },
281
+ }));
282
+ const cli = fixtures_1.makeCli();
283
+ const context = fixtures_1.createMockContext();
284
+ const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
285
+ process.env.DATADOG_API_KEY = '1234';
286
+ const code = yield cli.run([
287
+ 'lambda',
288
+ 'instrument',
289
+ '-f',
290
+ functionARN,
291
+ '--dry',
292
+ '-v',
293
+ '129',
294
+ '--extra-tags',
295
+ 'layer:api,team:intake',
296
+ '--service',
297
+ 'middletier',
298
+ '--env',
299
+ 'staging',
300
+ '--version',
301
+ '0.2',
302
+ ], context);
303
+ const output = context.stdout.toString();
304
+ expect(code).toBe(0);
305
+ expect(output).toMatchInlineSnapshot(`
306
+ "${chalk_1.bold(chalk_1.yellow('[Warning]'))} Instrument your ${chalk_1.hex('#FF9900').bold('Lambda')} functions in a dev or staging environment first. Should the instrumentation result be unsatisfactory, run \`${chalk_1.bold('uninstrument')}\` with the same arguments to revert the changes.
307
+ \n${chalk_1.bold(chalk_1.yellow('[!]'))} Functions to be updated:
308
+ \t- ${chalk_1.bold('arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world')}\n
309
+ ${chalk_1.bold(chalk_1.cyan('[Dry Run] '))}Will apply the following updates:
310
+ UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
311
+ {
312
+ \\"FunctionName\\": \\"arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world\\",
313
+ \\"Environment\\": {
314
+ \\"Variables\\": {
315
+ \\"DD_API_KEY\\": \\"1234\\",
316
+ \\"DD_SITE\\": \\"datadoghq.com\\",
317
+ \\"DD_CAPTURE_LAMBDA_PAYLOAD\\": \\"false\\",
318
+ \\"DD_ENV\\": \\"staging\\",
319
+ \\"DD_TAGS\\": \\"layer:api,team:intake\\",
320
+ \\"DD_MERGE_XRAY_TRACES\\": \\"false\\",
321
+ \\"DD_SERVICE\\": \\"middletier\\",
322
+ \\"DD_TRACE_ENABLED\\": \\"true\\",
323
+ \\"DD_VERSION\\": \\"0.2\\",
324
+ \\"DD_FLUSH_TO_LOG\\": \\"true\\",
325
+ \\"CORECLR_ENABLE_PROFILING\\": \\"1\\",
326
+ \\"CORECLR_PROFILER\\": \\"{846F5F1C-F9AE-4B07-969E-05C26BC060D8}\\",
327
+ \\"CORECLR_PROFILER_PATH\\": \\"/opt/datadog/Datadog.Trace.ClrProfiler.Native.so\\",
328
+ \\"DD_DOTNET_TRACER_HOME\\": \\"/opt/datadog\\"
329
+ }
330
+ },
331
+ \\"Layers\\": [
332
+ \\"arn:aws:lambda:us-east-1:464622532012:layer:dd-trace-dotnet:129\\"
333
+ ]
334
+ }
335
+ TagResource -> arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world
336
+ {
337
+ \\"dd_sls_ci\\": \\"v${version}\\"
338
+ }
339
+ "
271
340
  `);
272
341
  }));
273
342
  test('instrumenting with source code integrations fails if not run within a git repo', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -1044,6 +1113,155 @@ ${chalk_1.red('[Error]')} Couldn't find any Lambda functions in the specified re
1044
1113
  "Fetching Lambda functions, this might take a while.
1045
1114
  ${chalk_1.red('[Error]')} Couldn't fetch Lambda functions. Error: Max retry count exceeded.
1046
1115
  "
1116
+ `);
1117
+ }));
1118
+ test('aborts early when a layer version is set for Java', () => __awaiter(void 0, void 0, void 0, function* () {
1119
+ ;
1120
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1121
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
1122
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
1123
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
1124
+ Runtime: 'java8.al2',
1125
+ },
1126
+ }));
1127
+ const cli = fixtures_1.makeCli();
1128
+ const context = fixtures_1.createMockContext();
1129
+ const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
1130
+ process.env.DATADOG_API_KEY = '1234';
1131
+ const code = yield cli.run([
1132
+ 'lambda',
1133
+ 'instrument',
1134
+ '-f',
1135
+ functionARN,
1136
+ '--dry',
1137
+ '-v',
1138
+ '6',
1139
+ '--extra-tags',
1140
+ 'layer:api,team:intake',
1141
+ '--service',
1142
+ 'middletier',
1143
+ '--env',
1144
+ 'staging',
1145
+ '--version',
1146
+ '0.2',
1147
+ ], context);
1148
+ const output = context.stdout.toString();
1149
+ expect(code).toBe(1);
1150
+ expect(output).toMatchInlineSnapshot(`
1151
+ "${chalk_1.red('[Error]')} Couldn't fetch Lambda functions. Error: Only the --extension-version argument should be set for the java8.al2 runtime. Please remove the --layer-version argument from the instrument command.
1152
+ "
1153
+ `);
1154
+ }));
1155
+ test('aborts early when a layer version is set for Ruby', () => __awaiter(void 0, void 0, void 0, function* () {
1156
+ ;
1157
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1158
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
1159
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
1160
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
1161
+ Runtime: 'ruby2.7',
1162
+ },
1163
+ }));
1164
+ const cli = fixtures_1.makeCli();
1165
+ const context = fixtures_1.createMockContext();
1166
+ const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
1167
+ process.env.DATADOG_API_KEY = '1234';
1168
+ const code = yield cli.run([
1169
+ 'lambda',
1170
+ 'instrument',
1171
+ '-f',
1172
+ functionARN,
1173
+ '--dry',
1174
+ '-v',
1175
+ '40',
1176
+ '--extra-tags',
1177
+ 'layer:api,team:intake',
1178
+ '--service',
1179
+ 'middletier',
1180
+ '--env',
1181
+ 'staging',
1182
+ '--version',
1183
+ '0.2',
1184
+ ], context);
1185
+ const output = context.stdout.toString();
1186
+ expect(code).toBe(1);
1187
+ expect(output).toMatchInlineSnapshot(`
1188
+ "${chalk_1.red('[Error]')} Couldn't fetch Lambda functions. Error: Only the --extension-version argument should be set for the ruby2.7 runtime. Please remove the --layer-version argument from the instrument command.
1189
+ "
1190
+ `);
1191
+ }));
1192
+ test('aborts early when a layer version is set for a Custom runtime', () => __awaiter(void 0, void 0, void 0, function* () {
1193
+ ;
1194
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1195
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
1196
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
1197
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
1198
+ Runtime: 'provided.al2',
1199
+ },
1200
+ }));
1201
+ const cli = fixtures_1.makeCli();
1202
+ const context = fixtures_1.createMockContext();
1203
+ const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
1204
+ process.env.DATADOG_API_KEY = '1234';
1205
+ const code = yield cli.run([
1206
+ 'lambda',
1207
+ 'instrument',
1208
+ '-f',
1209
+ functionARN,
1210
+ '--dry',
1211
+ '-v',
1212
+ '6',
1213
+ '--extra-tags',
1214
+ 'layer:api,team:intake',
1215
+ '--service',
1216
+ 'middletier',
1217
+ '--env',
1218
+ 'staging',
1219
+ '--version',
1220
+ '0.2',
1221
+ ], context);
1222
+ const output = context.stdout.toString();
1223
+ expect(code).toBe(1);
1224
+ expect(output).toMatchInlineSnapshot(`
1225
+ "${chalk_1.red('[Error]')} Couldn't fetch Lambda functions. Error: Only the --extension-version argument should be set for the provided.al2 runtime. Please remove the --layer-version argument from the instrument command.
1226
+ "
1227
+ `);
1228
+ }));
1229
+ test('aborts early when .NET is using ARM64 architecture', () => __awaiter(void 0, void 0, void 0, function* () {
1230
+ ;
1231
+ fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
1232
+ aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
1233
+ 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world': {
1234
+ Architectures: ['arm64'],
1235
+ FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world',
1236
+ Runtime: 'dotnetcore3.1',
1237
+ },
1238
+ }));
1239
+ const cli = fixtures_1.makeCli();
1240
+ const context = fixtures_1.createMockContext();
1241
+ const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
1242
+ process.env.DATADOG_API_KEY = '1234';
1243
+ const code = yield cli.run([
1244
+ 'lambda',
1245
+ 'instrument',
1246
+ '-f',
1247
+ functionARN,
1248
+ '--dry',
1249
+ '-v',
1250
+ '6',
1251
+ '--extra-tags',
1252
+ 'layer:api,team:intake',
1253
+ '--service',
1254
+ 'middletier',
1255
+ '--env',
1256
+ 'staging',
1257
+ '--version',
1258
+ '0.2',
1259
+ ], context);
1260
+ const output = context.stdout.toString();
1261
+ expect(code).toBe(1);
1262
+ expect(output).toMatchInlineSnapshot(`
1263
+ "${chalk_1.red('[Error]')} Couldn't fetch Lambda functions. Error: Instrumenting arm64 architecture is not currently supported for .NET. Please only instrument .NET functions using x86_64 architecture.
1264
+ "
1047
1265
  `);
1048
1266
  }));
1049
1267
  });
@@ -1,7 +1,9 @@
1
1
  export declare const DD_LAMBDA_EXTENSION_LAYER_NAME = "Datadog-Extension";
2
2
  export declare const EXTENSION_LAYER_KEY = "extension";
3
- export declare const RUNTIME_LAYER_LOOKUP: {
3
+ export declare const DOTNET_RUNTIME = "dotnetcore3.1";
4
+ export declare const LAYER_LOOKUP: {
4
5
  readonly extension: "Datadog-Extension";
6
+ readonly 'dotnetcore3.1': "dd-trace-dotnet";
5
7
  readonly 'nodejs12.x': "Datadog-Node12-x";
6
8
  readonly 'nodejs14.x': "Datadog-Node14-x";
7
9
  readonly 'python3.6': "Datadog-Python36";
@@ -9,31 +11,45 @@ export declare const RUNTIME_LAYER_LOOKUP: {
9
11
  readonly 'python3.8': "Datadog-Python38";
10
12
  readonly 'python3.9': "Datadog-Python39";
11
13
  };
12
- export declare type Runtime = Exclude<keyof typeof RUNTIME_LAYER_LOOKUP, typeof EXTENSION_LAYER_KEY>;
13
- export declare const ARM_RUNTIMES: string[];
14
- export declare const ARM64_ARCHITECTURE = "arm64";
15
- export declare const ARM_LAYER_SUFFIX = "-ARM";
16
14
  export declare enum RuntimeType {
17
- NODE = 0,
18
- PYTHON = 1
15
+ DOTNET = 0,
16
+ CUSTOM = 1,
17
+ JAVA = 2,
18
+ NODE = 3,
19
+ PYTHON = 4,
20
+ RUBY = 5
19
21
  }
20
22
  export declare const RUNTIME_LOOKUP: {
21
- [key: string]: RuntimeType;
22
- };
23
- export declare const HANDLER_LOCATION: {
24
- 'nodejs12.x': string;
25
- 'nodejs14.x': string;
26
- 'python3.6': string;
27
- 'python3.7': string;
28
- 'python3.8': string;
29
- 'python3.9': string;
23
+ 'dotnetcore3.1': RuntimeType;
24
+ java11: RuntimeType;
25
+ 'java8.al2': RuntimeType;
26
+ 'nodejs12.x': RuntimeType;
27
+ 'nodejs14.x': RuntimeType;
28
+ 'provided.al2': RuntimeType;
29
+ 'python3.6': RuntimeType;
30
+ 'python3.7': RuntimeType;
31
+ 'python3.8': RuntimeType;
32
+ 'python3.9': RuntimeType;
33
+ 'ruby2.5': RuntimeType;
34
+ 'ruby2.7': RuntimeType;
30
35
  };
36
+ export declare type Runtime = keyof typeof RUNTIME_LOOKUP;
37
+ export declare type LayerKey = keyof typeof LAYER_LOOKUP;
38
+ export declare const ARM_LAYERS: string[];
39
+ export declare const ARM64_ARCHITECTURE = "arm64";
40
+ export declare const ARM_LAYER_SUFFIX = "-ARM";
41
+ export declare const PYTHON_HANDLER_LOCATION = "datadog_lambda.handler.handler";
42
+ export declare const NODE_HANDLER_LOCATION = "/opt/nodejs/node_modules/datadog-lambda-js/handler.handler";
31
43
  export declare const SITES: string[];
32
44
  export declare const AWS_REGIONS: string[];
33
45
  export declare const DEFAULT_LAYER_AWS_ACCOUNT = "464622532012";
34
46
  export declare const GOVCLOUD_LAYER_AWS_ACCOUNT = "002406178527";
35
47
  export declare const SUBSCRIPTION_FILTER_NAME = "datadog-ci-filter";
36
48
  export declare const TAG_VERSION_NAME = "dd_sls_ci";
49
+ export declare const CORECLR_ENABLE_PROFILING = "1";
50
+ export declare const CORECLR_PROFILER = "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}";
51
+ export declare const CORECLR_PROFILER_PATH = "/opt/datadog/Datadog.Trace.ClrProfiler.Native.so";
52
+ export declare const DD_DOTNET_TRACER_HOME = "/opt/datadog";
37
53
  export declare const API_KEY_ENV_VAR = "DD_API_KEY";
38
54
  export declare const API_KEY_SECRET_ARN_ENV_VAR = "DD_API_KEY_SECRET_ARN";
39
55
  export declare const KMS_API_KEY_ENV_VAR = "DD_KMS_API_KEY";
@@ -48,6 +64,10 @@ export declare const VERSION_ENV_VAR = "DD_VERSION";
48
64
  export declare const ENVIRONMENT_ENV_VAR = "DD_ENV";
49
65
  export declare const EXTRA_TAGS_ENV_VAR = "DD_TAGS";
50
66
  export declare const CAPTURE_LAMBDA_PAYLOAD_ENV_VAR = "DD_CAPTURE_LAMBDA_PAYLOAD";
67
+ export declare const ENABLE_PROFILING_ENV_VAR = "CORECLR_ENABLE_PROFILING";
68
+ export declare const PROFILER_ENV_VAR = "CORECLR_PROFILER";
69
+ export declare const PROFILER_PATH_ENV_VAR = "CORECLR_PROFILER_PATH";
70
+ export declare const DOTNET_TRACER_HOME_ENV_VAR = "DD_DOTNET_TRACER_HOME";
51
71
  export declare const CI_SITE_ENV_VAR = "DATADOG_SITE";
52
72
  export declare const CI_API_KEY_ENV_VAR = "DATADOG_API_KEY";
53
73
  export declare const CI_API_KEY_SECRET_ARN_ENV_VAR = "DATADOG_API_KEY_SECRET_ARN";
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DATADOG_APP_KEY_REG_EXP = exports.DATADOG_API_KEY_REG_EXP = exports.AWS_SECRET_ACCESS_KEY_REG_EXP = exports.AWS_ACCESS_KEY_ID_REG_EXP = exports.EXTRA_TAGS_REG_EXP = exports.MAX_LAMBDA_STATE_CHECK_ATTEMPTS = exports.LIST_FUNCTIONS_MAX_RETRY_COUNT = exports.AWS_SESSION_TOKEN_ENV_VAR = exports.AWS_DEFAULT_REGION_ENV_VAR = exports.AWS_SECRET_ACCESS_KEY_ENV_VAR = exports.AWS_ACCESS_KEY_ID_ENV_VAR = exports.CI_KMS_API_KEY_ENV_VAR = exports.CI_API_KEY_SECRET_ARN_ENV_VAR = exports.CI_API_KEY_ENV_VAR = exports.CI_SITE_ENV_VAR = exports.CAPTURE_LAMBDA_PAYLOAD_ENV_VAR = exports.EXTRA_TAGS_ENV_VAR = exports.ENVIRONMENT_ENV_VAR = exports.VERSION_ENV_VAR = exports.SERVICE_ENV_VAR = exports.LAMBDA_HANDLER_ENV_VAR = exports.LOG_LEVEL_ENV_VAR = exports.FLUSH_TO_LOG_ENV_VAR = exports.MERGE_XRAY_TRACES_ENV_VAR = exports.TRACE_ENABLED_ENV_VAR = exports.SITE_ENV_VAR = exports.KMS_API_KEY_ENV_VAR = exports.API_KEY_SECRET_ARN_ENV_VAR = exports.API_KEY_ENV_VAR = exports.TAG_VERSION_NAME = exports.SUBSCRIPTION_FILTER_NAME = exports.GOVCLOUD_LAYER_AWS_ACCOUNT = exports.DEFAULT_LAYER_AWS_ACCOUNT = exports.AWS_REGIONS = exports.SITES = exports.HANDLER_LOCATION = exports.RUNTIME_LOOKUP = exports.RuntimeType = exports.ARM_LAYER_SUFFIX = exports.ARM64_ARCHITECTURE = exports.ARM_RUNTIMES = exports.RUNTIME_LAYER_LOOKUP = exports.EXTENSION_LAYER_KEY = exports.DD_LAMBDA_EXTENSION_LAYER_NAME = void 0;
3
+ exports.EXTRA_TAGS_REG_EXP = exports.MAX_LAMBDA_STATE_CHECK_ATTEMPTS = exports.LIST_FUNCTIONS_MAX_RETRY_COUNT = exports.AWS_SESSION_TOKEN_ENV_VAR = exports.AWS_DEFAULT_REGION_ENV_VAR = exports.AWS_SECRET_ACCESS_KEY_ENV_VAR = exports.AWS_ACCESS_KEY_ID_ENV_VAR = exports.CI_KMS_API_KEY_ENV_VAR = exports.CI_API_KEY_SECRET_ARN_ENV_VAR = exports.CI_API_KEY_ENV_VAR = exports.CI_SITE_ENV_VAR = exports.DOTNET_TRACER_HOME_ENV_VAR = exports.PROFILER_PATH_ENV_VAR = exports.PROFILER_ENV_VAR = exports.ENABLE_PROFILING_ENV_VAR = exports.CAPTURE_LAMBDA_PAYLOAD_ENV_VAR = exports.EXTRA_TAGS_ENV_VAR = exports.ENVIRONMENT_ENV_VAR = exports.VERSION_ENV_VAR = exports.SERVICE_ENV_VAR = exports.LAMBDA_HANDLER_ENV_VAR = exports.LOG_LEVEL_ENV_VAR = exports.FLUSH_TO_LOG_ENV_VAR = exports.MERGE_XRAY_TRACES_ENV_VAR = exports.TRACE_ENABLED_ENV_VAR = exports.SITE_ENV_VAR = exports.KMS_API_KEY_ENV_VAR = exports.API_KEY_SECRET_ARN_ENV_VAR = exports.API_KEY_ENV_VAR = exports.DD_DOTNET_TRACER_HOME = exports.CORECLR_PROFILER_PATH = exports.CORECLR_PROFILER = exports.CORECLR_ENABLE_PROFILING = exports.TAG_VERSION_NAME = exports.SUBSCRIPTION_FILTER_NAME = exports.GOVCLOUD_LAYER_AWS_ACCOUNT = exports.DEFAULT_LAYER_AWS_ACCOUNT = exports.AWS_REGIONS = exports.SITES = exports.NODE_HANDLER_LOCATION = exports.PYTHON_HANDLER_LOCATION = exports.ARM_LAYER_SUFFIX = exports.ARM64_ARCHITECTURE = exports.ARM_LAYERS = exports.RUNTIME_LOOKUP = exports.RuntimeType = exports.LAYER_LOOKUP = exports.DOTNET_RUNTIME = exports.EXTENSION_LAYER_KEY = exports.DD_LAMBDA_EXTENSION_LAYER_NAME = void 0;
4
+ exports.DATADOG_APP_KEY_REG_EXP = exports.DATADOG_API_KEY_REG_EXP = exports.AWS_SECRET_ACCESS_KEY_REG_EXP = exports.AWS_ACCESS_KEY_ID_REG_EXP = void 0;
4
5
  exports.DD_LAMBDA_EXTENSION_LAYER_NAME = 'Datadog-Extension';
5
6
  exports.EXTENSION_LAYER_KEY = 'extension';
6
- exports.RUNTIME_LAYER_LOOKUP = {
7
+ exports.DOTNET_RUNTIME = 'dotnetcore3.1';
8
+ exports.LAYER_LOOKUP = {
7
9
  [exports.EXTENSION_LAYER_KEY]: exports.DD_LAMBDA_EXTENSION_LAYER_NAME,
10
+ 'dotnetcore3.1': 'dd-trace-dotnet',
8
11
  'nodejs12.x': 'Datadog-Node12-x',
9
12
  'nodejs14.x': 'Datadog-Node14-x',
10
13
  'python3.6': 'Datadog-Python36',
@@ -12,32 +15,34 @@ exports.RUNTIME_LAYER_LOOKUP = {
12
15
  'python3.8': 'Datadog-Python38',
13
16
  'python3.9': 'Datadog-Python39',
14
17
  };
15
- exports.ARM_RUNTIMES = [exports.EXTENSION_LAYER_KEY, 'python3.8', 'python3.9'];
16
- exports.ARM64_ARCHITECTURE = 'arm64';
17
- exports.ARM_LAYER_SUFFIX = '-ARM';
18
18
  var RuntimeType;
19
19
  (function (RuntimeType) {
20
- RuntimeType[RuntimeType["NODE"] = 0] = "NODE";
21
- RuntimeType[RuntimeType["PYTHON"] = 1] = "PYTHON";
20
+ RuntimeType[RuntimeType["DOTNET"] = 0] = "DOTNET";
21
+ RuntimeType[RuntimeType["CUSTOM"] = 1] = "CUSTOM";
22
+ RuntimeType[RuntimeType["JAVA"] = 2] = "JAVA";
23
+ RuntimeType[RuntimeType["NODE"] = 3] = "NODE";
24
+ RuntimeType[RuntimeType["PYTHON"] = 4] = "PYTHON";
25
+ RuntimeType[RuntimeType["RUBY"] = 5] = "RUBY";
22
26
  })(RuntimeType = exports.RuntimeType || (exports.RuntimeType = {}));
23
27
  exports.RUNTIME_LOOKUP = {
28
+ 'dotnetcore3.1': RuntimeType.DOTNET,
29
+ java11: RuntimeType.JAVA,
30
+ 'java8.al2': RuntimeType.JAVA,
24
31
  'nodejs12.x': RuntimeType.NODE,
25
32
  'nodejs14.x': RuntimeType.NODE,
33
+ 'provided.al2': RuntimeType.CUSTOM,
26
34
  'python3.6': RuntimeType.PYTHON,
27
35
  'python3.7': RuntimeType.PYTHON,
28
36
  'python3.8': RuntimeType.PYTHON,
29
37
  'python3.9': RuntimeType.PYTHON,
38
+ 'ruby2.5': RuntimeType.RUBY,
39
+ 'ruby2.7': RuntimeType.RUBY,
30
40
  };
31
- const PYTHON_HANDLER_LOCATION = 'datadog_lambda.handler.handler';
32
- const NODE_HANDLER_LOCATION = '/opt/nodejs/node_modules/datadog-lambda-js/handler.handler';
33
- exports.HANDLER_LOCATION = {
34
- 'nodejs12.x': NODE_HANDLER_LOCATION,
35
- 'nodejs14.x': NODE_HANDLER_LOCATION,
36
- 'python3.6': PYTHON_HANDLER_LOCATION,
37
- 'python3.7': PYTHON_HANDLER_LOCATION,
38
- 'python3.8': PYTHON_HANDLER_LOCATION,
39
- 'python3.9': PYTHON_HANDLER_LOCATION,
40
- };
41
+ exports.ARM_LAYERS = [exports.EXTENSION_LAYER_KEY, 'python3.8', 'python3.9'];
42
+ exports.ARM64_ARCHITECTURE = 'arm64';
43
+ exports.ARM_LAYER_SUFFIX = '-ARM';
44
+ exports.PYTHON_HANDLER_LOCATION = 'datadog_lambda.handler.handler';
45
+ exports.NODE_HANDLER_LOCATION = '/opt/nodejs/node_modules/datadog-lambda-js/handler.handler';
41
46
  exports.SITES = [
42
47
  'datadoghq.com',
43
48
  'datadoghq.eu',
@@ -74,6 +79,11 @@ exports.DEFAULT_LAYER_AWS_ACCOUNT = '464622532012';
74
79
  exports.GOVCLOUD_LAYER_AWS_ACCOUNT = '002406178527';
75
80
  exports.SUBSCRIPTION_FILTER_NAME = 'datadog-ci-filter';
76
81
  exports.TAG_VERSION_NAME = 'dd_sls_ci';
82
+ // Export const values for .NET tracer
83
+ exports.CORECLR_ENABLE_PROFILING = '1';
84
+ exports.CORECLR_PROFILER = '{846F5F1C-F9AE-4B07-969E-05C26BC060D8}';
85
+ exports.CORECLR_PROFILER_PATH = '/opt/datadog/Datadog.Trace.ClrProfiler.Native.so';
86
+ exports.DD_DOTNET_TRACER_HOME = '/opt/datadog';
77
87
  // Environment variables used in the Lambda environment
78
88
  exports.API_KEY_ENV_VAR = 'DD_API_KEY';
79
89
  exports.API_KEY_SECRET_ARN_ENV_VAR = 'DD_API_KEY_SECRET_ARN';
@@ -89,6 +99,10 @@ exports.VERSION_ENV_VAR = 'DD_VERSION';
89
99
  exports.ENVIRONMENT_ENV_VAR = 'DD_ENV';
90
100
  exports.EXTRA_TAGS_ENV_VAR = 'DD_TAGS';
91
101
  exports.CAPTURE_LAMBDA_PAYLOAD_ENV_VAR = 'DD_CAPTURE_LAMBDA_PAYLOAD';
102
+ exports.ENABLE_PROFILING_ENV_VAR = 'CORECLR_ENABLE_PROFILING';
103
+ exports.PROFILER_ENV_VAR = 'CORECLR_PROFILER';
104
+ exports.PROFILER_PATH_ENV_VAR = 'CORECLR_PROFILER_PATH';
105
+ exports.DOTNET_TRACER_HOME_ENV_VAR = 'DD_DOTNET_TRACER_HOME';
92
106
  // Environment variables used by Datadog CI
93
107
  exports.CI_SITE_ENV_VAR = 'DATADOG_SITE';
94
108
  exports.CI_API_KEY_ENV_VAR = 'DATADOG_API_KEY';
@@ -1,5 +1,5 @@
1
1
  import { CloudWatchLogs, Lambda } from 'aws-sdk';
2
- import { Runtime } from '../constants';
2
+ import { LayerKey } from '../constants';
3
3
  import { FunctionConfiguration, InstrumentationSettings } from '../interfaces';
4
4
  /**
5
5
  * Returns an array of merged layer ARNs if given a Full Layer ARN,
@@ -39,12 +39,13 @@ export declare const collectFunctionsByRegion: (functions: string[], defaultRegi
39
39
  * @param region the region where the layer is stored.
40
40
  * @returns the latest version of the layer to find.
41
41
  */
42
- export declare const findLatestLayerVersion: (runtime: Runtime, region: string) => Promise<number>;
42
+ export declare const findLatestLayerVersion: (layer: LayerKey, region: string) => Promise<number>;
43
43
  export declare const isMissingAWSCredentials: () => boolean;
44
44
  export declare const isMissingDatadogSiteEnvVar: () => boolean;
45
45
  export declare const isMissingAnyDatadogApiKeyEnvVar: () => boolean;
46
46
  export declare const isMissingDatadogEnvVars: () => boolean;
47
47
  export declare const getAllLambdaFunctionConfigs: (lambda: Lambda) => Promise<Lambda.FunctionConfiguration[]>;
48
+ export declare const checkRuntimeTypesAreUniform: (configList: FunctionConfiguration[]) => boolean;
48
49
  /**
49
50
  * Given a Lambda instance and a regular expression,
50
51
  * returns all the Function Configurations that match.
@@ -73,7 +74,7 @@ export declare const getLambdaFunctionConfigs: (lambda: Lambda, functionARNs: st
73
74
  * @param settings instrumentation settings, mainly used to change the AWS account that contains the Layer.
74
75
  * @returns the ARN of a **Specific Runtime Layer** with the correct region, account, architecture, and name.
75
76
  */
76
- export declare const getLayerArn: (config: Lambda.FunctionConfiguration, runtime: Runtime, region: string, settings?: InstrumentationSettings | undefined) => string;
77
+ export declare const getLayerArn: (config: Lambda.FunctionConfiguration, layer: LayerKey, region: string, settings?: InstrumentationSettings | undefined) => string;
77
78
  export declare const getLayerNameWithVersion: (layerArn: string) => string | undefined;
78
79
  export declare const getLayers: (config: Lambda.FunctionConfiguration) => string[];
79
80
  /**
@@ -110,7 +111,8 @@ export declare const isLambdaActive: (lambda: Lambda, config: Lambda.FunctionCon
110
111
  * @param runtime a string representing a Lambda FunctionConfiguration Runtime.
111
112
  * @returns if a runtime is supported.
112
113
  */
113
- export declare const isSupportedRuntime: (runtime?: string | undefined) => runtime is Runtime;
114
+ export declare const isSupportedRuntime: (runtime?: string | undefined) => runtime is "nodejs12.x" | "nodejs14.x" | "java8.al2" | "java11" | "python3.6" | "python3.7" | "python3.8" | "python3.9" | "dotnetcore3.1" | "ruby2.5" | "ruby2.7" | "provided.al2";
115
+ export declare const isLayerRuntime: (runtime: string) => runtime is "nodejs12.x" | "nodejs14.x" | "python3.6" | "python3.7" | "python3.8" | "python3.9" | "dotnetcore3.1" | "extension";
114
116
  export declare const sentenceMatchesRegEx: (sentence: string, regex: RegExp) => RegExpMatchArray | null;
115
117
  export declare const updateLambdaFunctionConfigs: (lambda: Lambda, cloudWatch: CloudWatchLogs, configs: FunctionConfiguration[]) => Promise<void>;
116
118
  export declare const willUpdateFunctionConfigs: (configs: FunctionConfiguration[]) => boolean;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.willUpdateFunctionConfigs = exports.updateLambdaFunctionConfigs = exports.sentenceMatchesRegEx = exports.isSupportedRuntime = exports.isLambdaActive = exports.getRegion = exports.getLambdaFunctionConfig = exports.getLayers = exports.getLayerNameWithVersion = exports.getLayerArn = exports.getLambdaFunctionConfigs = exports.getLambdaFunctionConfigsFromRegex = exports.getAllLambdaFunctionConfigs = exports.isMissingDatadogEnvVars = exports.isMissingAnyDatadogApiKeyEnvVar = exports.isMissingDatadogSiteEnvVar = exports.isMissingAWSCredentials = exports.findLatestLayerVersion = exports.collectFunctionsByRegion = exports.coerceBoolean = exports.addLayerArn = void 0;
12
+ exports.willUpdateFunctionConfigs = exports.updateLambdaFunctionConfigs = exports.sentenceMatchesRegEx = exports.isLayerRuntime = exports.isSupportedRuntime = exports.isLambdaActive = exports.getRegion = exports.getLambdaFunctionConfig = exports.getLayers = exports.getLayerNameWithVersion = exports.getLayerArn = exports.getLambdaFunctionConfigs = exports.getLambdaFunctionConfigsFromRegex = exports.checkRuntimeTypesAreUniform = exports.getAllLambdaFunctionConfigs = exports.isMissingDatadogEnvVars = exports.isMissingAnyDatadogApiKeyEnvVar = exports.isMissingDatadogSiteEnvVar = exports.isMissingAWSCredentials = exports.findLatestLayerVersion = exports.collectFunctionsByRegion = exports.coerceBoolean = exports.addLayerArn = void 0;
13
13
  const aws_sdk_1 = require("aws-sdk");
14
14
  const constants_1 = require("../constants");
15
15
  const loggroup_1 = require("../loggroup");
@@ -99,12 +99,12 @@ exports.collectFunctionsByRegion = collectFunctionsByRegion;
99
99
  * @param region the region where the layer is stored.
100
100
  * @returns the latest version of the layer to find.
101
101
  */
102
- const findLatestLayerVersion = (runtime, region) => __awaiter(void 0, void 0, void 0, function* () {
102
+ const findLatestLayerVersion = (layer, region) => __awaiter(void 0, void 0, void 0, function* () {
103
103
  let latestVersion = 0;
104
104
  let searchStep = latestVersion > 0 ? 1 : 100;
105
105
  let layerVersion = latestVersion + searchStep;
106
106
  const account = region.startsWith('us-gov') ? constants_1.GOVCLOUD_LAYER_AWS_ACCOUNT : constants_1.DEFAULT_LAYER_AWS_ACCOUNT;
107
- const layerName = constants_1.RUNTIME_LAYER_LOOKUP[runtime];
107
+ const layerName = constants_1.LAYER_LOOKUP[layer];
108
108
  let foundLatestVersion = false;
109
109
  const lambda = new aws_sdk_1.Lambda({ region });
110
110
  while (!foundLatestVersion) {
@@ -173,6 +173,11 @@ const isMissingDatadogEnvVars = () => exports.isMissingDatadogSiteEnvVar() || ex
173
173
  exports.isMissingDatadogEnvVars = isMissingDatadogEnvVars;
174
174
  const getAllLambdaFunctionConfigs = (lambda) => __awaiter(void 0, void 0, void 0, function* () { return exports.getLambdaFunctionConfigsFromRegex(lambda, '.'); });
175
175
  exports.getAllLambdaFunctionConfigs = getAllLambdaFunctionConfigs;
176
+ // Returns false if not all runtimes are of the same RuntimeType across multiple functions
177
+ const checkRuntimeTypesAreUniform = (configList) => configList
178
+ .map((item) => item.lambdaConfig.Runtime)
179
+ .every((runtime) => constants_1.RUNTIME_LOOKUP[runtime] === constants_1.RUNTIME_LOOKUP[configList[0].lambdaConfig.Runtime]);
180
+ exports.checkRuntimeTypesAreUniform = checkRuntimeTypesAreUniform;
176
181
  /**
177
182
  * Given a Lambda instance and a regular expression,
178
183
  * returns all the Function Configurations that match.
@@ -231,10 +236,10 @@ exports.getLambdaFunctionConfigs = getLambdaFunctionConfigs;
231
236
  * @param settings instrumentation settings, mainly used to change the AWS account that contains the Layer.
232
237
  * @returns the ARN of a **Specific Runtime Layer** with the correct region, account, architecture, and name.
233
238
  */
234
- const getLayerArn = (config, runtime, region, settings) => {
239
+ const getLayerArn = (config, layer, region, settings) => {
235
240
  var _a, _b;
236
- let layerName = constants_1.RUNTIME_LAYER_LOOKUP[runtime];
237
- if (constants_1.ARM_RUNTIMES.includes(runtime) && ((_a = config.Architectures) === null || _a === void 0 ? void 0 : _a.includes(constants_1.ARM64_ARCHITECTURE))) {
241
+ let layerName = constants_1.LAYER_LOOKUP[layer];
242
+ if (constants_1.ARM_LAYERS.includes(layer) && ((_a = config.Architectures) === null || _a === void 0 ? void 0 : _a.includes(constants_1.ARM64_ARCHITECTURE))) {
238
243
  layerName += constants_1.ARM_LAYER_SUFFIX;
239
244
  }
240
245
  const account = (_b = settings === null || settings === void 0 ? void 0 : settings.layerAWSAccount) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_LAYER_AWS_ACCOUNT;
@@ -315,11 +320,10 @@ exports.isLambdaActive = isLambdaActive;
315
320
  * @param runtime a string representing a Lambda FunctionConfiguration Runtime.
316
321
  * @returns if a runtime is supported.
317
322
  */
318
- const isSupportedRuntime = (runtime) => {
319
- const lookup = constants_1.RUNTIME_LAYER_LOOKUP;
320
- return runtime !== undefined && lookup[runtime] !== undefined;
321
- };
323
+ const isSupportedRuntime = (runtime) => runtime !== undefined && constants_1.RUNTIME_LOOKUP[runtime] !== undefined;
322
324
  exports.isSupportedRuntime = isSupportedRuntime;
325
+ const isLayerRuntime = (runtime) => constants_1.LAYER_LOOKUP[runtime] !== undefined;
326
+ exports.isLayerRuntime = isLayerRuntime;
323
327
  const sentenceMatchesRegEx = (sentence, regex) => sentence.match(regex);
324
328
  exports.sentenceMatchesRegEx = sentenceMatchesRegEx;
325
329
  const updateLambdaFunctionConfigs = (lambda, cloudWatch, configs) => __awaiter(void 0, void 0, void 0, function* () {
@@ -58,7 +58,7 @@ const getInstrumentedFunctionConfigsFromRegEx = (lambda, cloudWatch, region, pat
58
58
  });
59
59
  exports.getInstrumentedFunctionConfigsFromRegEx = getInstrumentedFunctionConfigsFromRegEx;
60
60
  const calculateUpdateRequest = (config, settings, region, runtime) => __awaiter(void 0, void 0, void 0, function* () {
61
- var _a, _b, _c, _d;
61
+ var _a, _b, _c, _d, _e;
62
62
  const oldEnvVars = Object.assign({}, (_a = config.Environment) === null || _a === void 0 ? void 0 : _a.Variables);
63
63
  const changedEnvVars = {};
64
64
  const functionARN = config.FunctionArn;
@@ -73,16 +73,41 @@ const calculateUpdateRequest = (config, settings, region, runtime) => __awaiter(
73
73
  FunctionName: functionARN,
74
74
  };
75
75
  let needsUpdate = false;
76
- // Update Handler
77
- const expectedHandler = constants_1.HANDLER_LOCATION[runtime];
78
- if (config.Handler !== expectedHandler) {
79
- needsUpdate = true;
80
- updateRequest.Handler = constants_1.HANDLER_LOCATION[runtime];
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
+ }
81
104
  }
82
105
  // Update Env Vars
83
- if (oldEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR] === undefined) {
84
- needsUpdate = true;
85
- changedEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR] = (_b = config.Handler) !== null && _b !== void 0 ? _b : '';
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
+ }
86
111
  }
87
112
  // KMS > Secrets Manager > API Key
88
113
  if (apiKmsKey !== undefined && oldEnvVars[constants_1.KMS_API_KEY_ENV_VAR] !== apiKmsKey) {
@@ -125,7 +150,7 @@ const calculateUpdateRequest = (config, settings, region, runtime) => __awaiter(
125
150
  ['version', constants_1.VERSION_ENV_VAR],
126
151
  ];
127
152
  for (const [key, environmentVar] of environmentVarsTupleArray) {
128
- if (settings[key] !== undefined && oldEnvVars[environmentVar] !== ((_c = settings[key]) === null || _c === void 0 ? void 0 : _c.toString())) {
153
+ if (settings[key] !== undefined && oldEnvVars[environmentVar] !== ((_d = settings[key]) === null || _d === void 0 ? void 0 : _d.toString())) {
129
154
  needsUpdate = true;
130
155
  changedEnvVars[environmentVar] = settings[key].toString();
131
156
  }
@@ -134,7 +159,7 @@ const calculateUpdateRequest = (config, settings, region, runtime) => __awaiter(
134
159
  const isUsingExtension = settings.extensionVersion !== undefined;
135
160
  if (!isUsingExtension &&
136
161
  settings.flushMetricsToLogs !== undefined &&
137
- oldEnvVars[constants_1.FLUSH_TO_LOG_ENV_VAR] !== ((_d = settings.flushMetricsToLogs) === null || _d === void 0 ? void 0 : _d.toString())) {
162
+ oldEnvVars[constants_1.FLUSH_TO_LOG_ENV_VAR] !== ((_e = settings.flushMetricsToLogs) === null || _e === void 0 ? void 0 : _e.toString())) {
138
163
  needsUpdate = true;
139
164
  changedEnvVars[constants_1.FLUSH_TO_LOG_ENV_VAR] = settings.flushMetricsToLogs.toString();
140
165
  }
@@ -148,19 +173,31 @@ const calculateUpdateRequest = (config, settings, region, runtime) => __awaiter(
148
173
  delete newEnvVars[constants_1.LOG_LEVEL_ENV_VAR];
149
174
  }
150
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
+ }
151
183
  updateRequest.Environment = {
152
184
  Variables: newEnvVars,
153
185
  };
154
- // Update Layers
155
- const lambdaLibraryLayerArn = commons_1.getLayerArn(config, config.Runtime, region, settings);
156
- const lambraLibraryLayerName = constants_1.RUNTIME_LAYER_LOOKUP[runtime];
157
- let fullLambdaLibraryLayerARN;
158
- if (settings.layerVersion !== undefined || settings.interactive) {
159
- let layerVersion = settings.layerVersion;
160
- if (settings.interactive && !settings.layerVersion) {
161
- layerVersion = yield commons_1.findLatestLayerVersion(config.Runtime, region);
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}`;
162
199
  }
163
- fullLambdaLibraryLayerARN = `${lambdaLibraryLayerArn}:${layerVersion}`;
200
+ layerARNs = commons_1.addLayerArn(fullLambdaLibraryLayerARN, lambdaLibraryLayerName, layerARNs);
164
201
  }
165
202
  const lambdaExtensionLayerArn = commons_1.getLayerArn(config, constants_1.EXTENSION_LAYER_KEY, region, settings);
166
203
  let fullExtensionLayerARN;
@@ -171,10 +208,6 @@ const calculateUpdateRequest = (config, settings, region, runtime) => __awaiter(
171
208
  }
172
209
  fullExtensionLayerARN = `${lambdaExtensionLayerArn}:${extensionVersion}`;
173
210
  }
174
- let layerARNs = commons_1.getLayers(config);
175
- const originalLayerARNs = layerARNs;
176
- let needsLayerUpdate = false;
177
- layerARNs = commons_1.addLayerArn(fullLambdaLibraryLayerARN, lambraLibraryLayerName, layerARNs);
178
211
  layerARNs = commons_1.addLayerArn(fullExtensionLayerARN, constants_1.DD_LAMBDA_EXTENSION_LAYER_NAME, layerARNs);
179
212
  if (originalLayerARNs.sort().join(',') !== layerARNs.sort().join(',')) {
180
213
  needsLayerUpdate = true;
@@ -67,12 +67,23 @@ const calculateUpdateRequest = (config, runtime) => {
67
67
  FunctionName: functionARN,
68
68
  };
69
69
  let needsUpdate = false;
70
- // Remove Handler
71
- const expectedHandler = constants_1.HANDLER_LOCATION[runtime];
72
- if (config.Handler === expectedHandler) {
73
- needsUpdate = true;
74
- updateRequest.Handler = oldEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR];
75
- delete oldEnvVars[constants_1.LAMBDA_HANDLER_ENV_VAR];
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
+ }
76
87
  }
77
88
  /**
78
89
  * Array used to remove environment vars used in
@@ -92,6 +103,10 @@ const calculateUpdateRequest = (config, runtime) => {
92
103
  constants_1.SERVICE_ENV_VAR,
93
104
  constants_1.TRACE_ENABLED_ENV_VAR,
94
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,
95
110
  ];
96
111
  // Remove Environment Variables
97
112
  for (const environmentVar of environmentVarsArray) {
@@ -105,7 +120,7 @@ const calculateUpdateRequest = (config, runtime) => {
105
120
  };
106
121
  // Remove Layers
107
122
  let needsLayerRemoval = false;
108
- const lambdaLibraryLayerName = constants_1.RUNTIME_LAYER_LOOKUP[runtime];
123
+ const lambdaLibraryLayerName = constants_1.LAYER_LOOKUP[runtime];
109
124
  const originalLayerARNs = commons_1.getLayers(config);
110
125
  const layerARNs = ((_b = config.Layers) !== null && _b !== void 0 ? _b : [])
111
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)); })
@@ -155,6 +155,9 @@ class InstrumentCommand extends clipanion_1.Command {
155
155
  }
156
156
  }
157
157
  const configList = configGroups.map((group) => group.configs).reduce((a, b) => a.concat(b));
158
+ if (!commons_1.checkRuntimeTypesAreUniform(configList)) {
159
+ throw Error('Detected Lambda functions using different runtimes. Please only instrument batches of functions that share a similar runtime');
160
+ }
158
161
  this.printPlannedActions(configList);
159
162
  if (this.dryRun || configList.length === 0) {
160
163
  return 0;
@@ -291,6 +291,7 @@ describe('utils', () => {
291
291
  pollingTimeout: 60 * 1000,
292
292
  retry: { count: 5, interval: 30 },
293
293
  startUrl: 'http://127.0.0.1:60/newPath',
294
+ startUrlSubstitutionRegex: '.*',
294
295
  tunnel: { host: 'host', id: 'id', privateKey: 'privateKey' },
295
296
  variables: { VAR_1: 'value' },
296
297
  };
@@ -245,6 +245,7 @@ export interface ConfigOverride {
245
245
  pollingTimeout?: number;
246
246
  retry?: RetryConfig;
247
247
  startUrl?: string;
248
+ startUrlSubstitutionRegex?: string;
248
249
  tunnel?: TunnelInfo;
249
250
  variables?: {
250
251
  [key: string]: string;
@@ -28,6 +28,7 @@ export declare const getTestsList: (api: APIHelper, config: SyntheticsCIConfig,
28
28
  pollingTimeout?: number | undefined;
29
29
  retry?: import("./interfaces").RetryConfig | undefined;
30
30
  startUrl?: string | undefined;
31
+ startUrlSubstitutionRegex?: string | undefined;
31
32
  tunnel?: import("./tunnel").TunnelInfo | undefined;
32
33
  variables?: {
33
34
  [key: string]: string;
@@ -52,6 +53,7 @@ export declare const getTestsList: (api: APIHelper, config: SyntheticsCIConfig,
52
53
  pollingTimeout?: number | undefined;
53
54
  retry?: import("./interfaces").RetryConfig | undefined;
54
55
  startUrl?: string | undefined;
56
+ startUrlSubstitutionRegex?: string | undefined;
55
57
  tunnel?: import("./tunnel").TunnelInfo | undefined;
56
58
  variables?: {
57
59
  [key: string]: string;
@@ -69,11 +69,15 @@ const handleConfig = (test, publicId, reporter, config) => {
69
69
  'locations',
70
70
  'pollingTimeout',
71
71
  'retry',
72
+ 'startUrlSubstitutionRegex',
72
73
  'tunnel',
73
74
  'variables',
74
75
  ]));
75
76
  if ((test.type === 'browser' || test.subtype === 'http') && config.startUrl) {
76
77
  const context = parseUrlVariables(test.config.request.url, reporter);
78
+ if (URL_VARIABLES.some((v) => { var _a; return (_a = config.startUrl) === null || _a === void 0 ? void 0 : _a.includes(v); })) {
79
+ reporter.error('[DEPRECATION] The usage of URL variables is deprecated, see explanation in the README\n\n');
80
+ }
77
81
  handledConfig.startUrl = template(config.startUrl, context);
78
82
  }
79
83
  return handledConfig;
@@ -104,19 +108,20 @@ const parseUrlVariables = (url, reporter) => {
104
108
  context.SUBDOMAIN = subdomainMatch ? subdomainMatch[1] : undefined;
105
109
  return context;
106
110
  };
111
+ const URL_VARIABLES = [
112
+ 'DOMAIN',
113
+ 'HASH',
114
+ 'HOST',
115
+ 'HOSTNAME',
116
+ 'ORIGIN',
117
+ 'PARAMS',
118
+ 'PATHNAME',
119
+ 'PORT',
120
+ 'PROTOCOL',
121
+ 'SUBDOMAIN',
122
+ ];
107
123
  const warnOnReservedEnvVarNames = (context, reporter) => {
108
- const reservedVarNames = new Set([
109
- 'DOMAIN',
110
- 'HASH',
111
- 'HOST',
112
- 'HOSTNAME',
113
- 'ORIGIN',
114
- 'PARAMS',
115
- 'PATHNAME',
116
- 'PORT',
117
- 'PROTOCOL',
118
- 'SUBDOMAIN',
119
- ]);
124
+ const reservedVarNames = new Set(URL_VARIABLES);
120
125
  const usedEnvVarNames = Object.keys(context).filter((name) => reservedVarNames.has(name));
121
126
  if (usedEnvVarNames.length > 0) {
122
127
  const names = usedEnvVarNames.join(', ');
@@ -28,7 +28,7 @@ const getGitMetadata = () => __awaiter(void 0, void 0, void 0, function* () {
28
28
  git.branch(),
29
29
  git.listRemote(['--get-url']),
30
30
  git.show(['-s', '--format=%s']),
31
- git.show(['-s', '--format=%an,%ae,%ad,%cn,%ce,%cd']),
31
+ git.show(['-s', '--format=%an,%ae,%aI,%cn,%ce,%cI']),
32
32
  ]);
33
33
  const [authorName, authorEmail, authorDate, committerName, committerEmail, committerDate,] = authorAndCommitter.split(',');
34
34
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/datadog-ci",
3
- "version": "0.17.13",
3
+ "version": "0.18.0",
4
4
  "description": "Run datadog actions from the CI.",
5
5
  "repository": "https://github.com/DataDog/datadog-ci",
6
6
  "license": "Apache-2.0",