construct-hub 0.2.55 → 0.2.59
Sign up to get free protection for your applications and to get access to all the features.
- package/.gitattributes +0 -1
- package/.jsii +78 -11
- package/API.md +44 -0
- package/README.md +7 -0
- package/lib/backend/catalog-builder/catalog-builder.bundle/index.js +1 -1
- package/lib/backend/catalog-builder/catalog-builder.bundle/index.js.map +1 -1
- package/lib/backend/catalog-builder/catalog-builder.lambda.js +2 -2
- package/lib/backend/ingestion/ingestion.bundle/index.js +3 -3
- package/lib/backend/ingestion/ingestion.bundle/index.js.map +1 -1
- package/lib/backend/ingestion/ingestion.lambda.js +4 -4
- package/lib/backend/orchestration/index.js +3 -2
- package/lib/backend/package-stats/package-stats.bundle/index.js +1 -1
- package/lib/backend/package-stats/package-stats.bundle/index.js.map +1 -1
- package/lib/backend/package-stats/package-stats.lambda.js +2 -2
- package/lib/backend/transliterator/transliterator.bundle/index.js +6 -6
- package/lib/backend/transliterator/transliterator.bundle/index.js.map +1 -1
- package/lib/backend/transliterator/transliterator.ecstask.js +2 -2
- package/lib/construct-hub.d.ts +7 -1
- package/lib/construct-hub.js +3 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/package-sources/code-artifact.js +1 -1
- package/lib/package-sources/npmjs.js +1 -1
- package/lib/package-tag/index.js +2 -2
- package/lib/spdx-license.js +1 -1
- package/lib/webapp/config.d.ts +5 -1
- package/lib/webapp/config.js +2 -1
- package/lib/webapp/index.d.ts +16 -0
- package/lib/webapp/index.js +11 -4
- package/package.json +3 -4
- package/lib/webapp/cache-invalidator/constants.d.ts +0 -4
- package/lib/webapp/cache-invalidator/constants.js +0 -5
- package/lib/webapp/cache-invalidator/handler.bundle/index.js +0 -1404
- package/lib/webapp/cache-invalidator/handler.bundle/index.js.map +0 -7
- package/lib/webapp/cache-invalidator/handler.d.ts +0 -7
- package/lib/webapp/cache-invalidator/handler.js +0 -19
- package/lib/webapp/cache-invalidator/handler.lambda.d.ts +0 -3
- package/lib/webapp/cache-invalidator/handler.lambda.js +0 -42
- package/lib/webapp/cache-invalidator/index.d.ts +0 -34
- package/lib/webapp/cache-invalidator/index.js +0 -57
@@ -1,1404 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
9
|
-
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
10
|
-
};
|
11
|
-
var __export = (target, all) => {
|
12
|
-
__markAsModule(target);
|
13
|
-
for (var name in all)
|
14
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
15
|
-
};
|
16
|
-
var __reExport = (target, module2, desc) => {
|
17
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
18
|
-
for (let key of __getOwnPropNames(module2))
|
19
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
20
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
21
|
-
}
|
22
|
-
return target;
|
23
|
-
};
|
24
|
-
var __toModule = (module2) => {
|
25
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
26
|
-
};
|
27
|
-
|
28
|
-
// node_modules/aws-embedded-metrics/lib/Constants.js
|
29
|
-
var require_Constants = __commonJS({
|
30
|
-
"node_modules/aws-embedded-metrics/lib/Constants.js"(exports) {
|
31
|
-
"use strict";
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
33
|
-
var Constants;
|
34
|
-
(function(Constants2) {
|
35
|
-
Constants2[Constants2["MAX_DIMENSIONS"] = 9] = "MAX_DIMENSIONS";
|
36
|
-
Constants2["DEFAULT_NAMESPACE"] = "aws-embedded-metrics";
|
37
|
-
Constants2[Constants2["MAX_METRICS_PER_EVENT"] = 100] = "MAX_METRICS_PER_EVENT";
|
38
|
-
Constants2["DEFAULT_AGENT_HOST"] = "0.0.0.0";
|
39
|
-
Constants2[Constants2["DEFAULT_AGENT_PORT"] = 25888] = "DEFAULT_AGENT_PORT";
|
40
|
-
})(Constants = exports.Constants || (exports.Constants = {}));
|
41
|
-
}
|
42
|
-
});
|
43
|
-
|
44
|
-
// node_modules/aws-embedded-metrics/lib/environment/Environments.js
|
45
|
-
var require_Environments = __commonJS({
|
46
|
-
"node_modules/aws-embedded-metrics/lib/environment/Environments.js"(exports) {
|
47
|
-
"use strict";
|
48
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
49
|
-
var Environments;
|
50
|
-
(function(Environments2) {
|
51
|
-
Environments2["Local"] = "Local";
|
52
|
-
Environments2["Lambda"] = "Lambda";
|
53
|
-
Environments2["Agent"] = "Agent";
|
54
|
-
Environments2["EC2"] = "EC2";
|
55
|
-
Environments2["ECS"] = "ECS";
|
56
|
-
Environments2["Unknown"] = "";
|
57
|
-
})(Environments || (Environments = {}));
|
58
|
-
exports.default = Environments;
|
59
|
-
}
|
60
|
-
});
|
61
|
-
|
62
|
-
// node_modules/aws-embedded-metrics/lib/config/EnvironmentConfigurationProvider.js
|
63
|
-
var require_EnvironmentConfigurationProvider = __commonJS({
|
64
|
-
"node_modules/aws-embedded-metrics/lib/config/EnvironmentConfigurationProvider.js"(exports) {
|
65
|
-
"use strict";
|
66
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
67
|
-
var Constants_1 = require_Constants();
|
68
|
-
var Environments_1 = require_Environments();
|
69
|
-
var ENV_VAR_PREFIX = "AWS_EMF";
|
70
|
-
var ConfigKeys;
|
71
|
-
(function(ConfigKeys2) {
|
72
|
-
ConfigKeys2["LOG_GROUP_NAME"] = "LOG_GROUP_NAME";
|
73
|
-
ConfigKeys2["LOG_STREAM_NAME"] = "LOG_STREAM_NAME";
|
74
|
-
ConfigKeys2["ENABLE_DEBUG_LOGGING"] = "ENABLE_DEBUG_LOGGING";
|
75
|
-
ConfigKeys2["SERVICE_NAME"] = "SERVICE_NAME";
|
76
|
-
ConfigKeys2["SERVICE_TYPE"] = "SERVICE_TYPE";
|
77
|
-
ConfigKeys2["AGENT_ENDPOINT"] = "AGENT_ENDPOINT";
|
78
|
-
ConfigKeys2["ENVIRONMENT_OVERRIDE"] = "ENVIRONMENT";
|
79
|
-
ConfigKeys2["NAMESPACE"] = "NAMESPACE";
|
80
|
-
})(ConfigKeys || (ConfigKeys = {}));
|
81
|
-
var EnvironmentConfigurationProvider = class {
|
82
|
-
getConfiguration() {
|
83
|
-
return {
|
84
|
-
agentEndpoint: this.getEnvVariable(ConfigKeys.AGENT_ENDPOINT),
|
85
|
-
debuggingLoggingEnabled: this.tryGetEnvVariableAsBoolean(ConfigKeys.ENABLE_DEBUG_LOGGING, false),
|
86
|
-
logGroupName: this.getEnvVariable(ConfigKeys.LOG_GROUP_NAME),
|
87
|
-
logStreamName: this.getEnvVariable(ConfigKeys.LOG_STREAM_NAME),
|
88
|
-
serviceName: this.getEnvVariable(ConfigKeys.SERVICE_NAME) || this.getEnvVariableWithoutPrefix(ConfigKeys.SERVICE_NAME),
|
89
|
-
serviceType: this.getEnvVariable(ConfigKeys.SERVICE_TYPE) || this.getEnvVariableWithoutPrefix(ConfigKeys.SERVICE_TYPE),
|
90
|
-
environmentOverride: this.getEnvironmentOverride(),
|
91
|
-
namespace: this.getEnvVariable(ConfigKeys.NAMESPACE) || Constants_1.Constants.DEFAULT_NAMESPACE
|
92
|
-
};
|
93
|
-
}
|
94
|
-
getEnvVariableWithoutPrefix(configKey) {
|
95
|
-
return process.env[configKey];
|
96
|
-
}
|
97
|
-
getEnvVariable(configKey) {
|
98
|
-
return process.env[`${ENV_VAR_PREFIX}_${configKey}`];
|
99
|
-
}
|
100
|
-
tryGetEnvVariableAsBoolean(configKey, fallback) {
|
101
|
-
const configValue = this.getEnvVariable(configKey);
|
102
|
-
return !configValue ? fallback : configValue.toLowerCase() === "true";
|
103
|
-
}
|
104
|
-
getEnvironmentOverride() {
|
105
|
-
const overrideValue = this.getEnvVariable(ConfigKeys.ENVIRONMENT_OVERRIDE);
|
106
|
-
const environment = Environments_1.default[overrideValue];
|
107
|
-
if (environment === void 0) {
|
108
|
-
return Environments_1.default.Unknown;
|
109
|
-
}
|
110
|
-
return environment;
|
111
|
-
}
|
112
|
-
};
|
113
|
-
exports.EnvironmentConfigurationProvider = EnvironmentConfigurationProvider;
|
114
|
-
}
|
115
|
-
});
|
116
|
-
|
117
|
-
// node_modules/aws-embedded-metrics/lib/config/Configuration.js
|
118
|
-
var require_Configuration = __commonJS({
|
119
|
-
"node_modules/aws-embedded-metrics/lib/config/Configuration.js"(exports) {
|
120
|
-
"use strict";
|
121
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
122
|
-
var EnvironmentConfigurationProvider_1 = require_EnvironmentConfigurationProvider();
|
123
|
-
var Configuration = new EnvironmentConfigurationProvider_1.EnvironmentConfigurationProvider().getConfiguration();
|
124
|
-
exports.default = Configuration;
|
125
|
-
}
|
126
|
-
});
|
127
|
-
|
128
|
-
// node_modules/aws-embedded-metrics/lib/utils/Logger.js
|
129
|
-
var require_Logger = __commonJS({
|
130
|
-
"node_modules/aws-embedded-metrics/lib/utils/Logger.js"(exports) {
|
131
|
-
"use strict";
|
132
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
133
|
-
var Configuration_1 = require_Configuration();
|
134
|
-
var LOG = (...args) => {
|
135
|
-
if (Configuration_1.default.debuggingLoggingEnabled) {
|
136
|
-
console.log(...args);
|
137
|
-
}
|
138
|
-
};
|
139
|
-
exports.LOG = LOG;
|
140
|
-
}
|
141
|
-
});
|
142
|
-
|
143
|
-
// node_modules/aws-embedded-metrics/lib/logger/MetricValues.js
|
144
|
-
var require_MetricValues = __commonJS({
|
145
|
-
"node_modules/aws-embedded-metrics/lib/logger/MetricValues.js"(exports) {
|
146
|
-
"use strict";
|
147
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
148
|
-
var MetricValues = class {
|
149
|
-
constructor(value, unit) {
|
150
|
-
this.values = [value];
|
151
|
-
this.unit = unit || "None";
|
152
|
-
}
|
153
|
-
addValue(value) {
|
154
|
-
this.values.push(value);
|
155
|
-
}
|
156
|
-
};
|
157
|
-
exports.MetricValues = MetricValues;
|
158
|
-
}
|
159
|
-
});
|
160
|
-
|
161
|
-
// node_modules/aws-embedded-metrics/lib/logger/MetricsContext.js
|
162
|
-
var require_MetricsContext = __commonJS({
|
163
|
-
"node_modules/aws-embedded-metrics/lib/logger/MetricsContext.js"(exports) {
|
164
|
-
"use strict";
|
165
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
166
|
-
var Configuration_1 = require_Configuration();
|
167
|
-
var Logger_1 = require_Logger();
|
168
|
-
var MetricValues_1 = require_MetricValues();
|
169
|
-
var MetricsContext = class {
|
170
|
-
constructor(namespace, properties, dimensions, defaultDimensions, shouldUseDefaultDimensions, timestamp) {
|
171
|
-
this.metrics = new Map();
|
172
|
-
this.meta = {};
|
173
|
-
this.shouldUseDefaultDimensions = true;
|
174
|
-
this.namespace = namespace || Configuration_1.default.namespace;
|
175
|
-
this.properties = properties || {};
|
176
|
-
this.dimensions = dimensions || [];
|
177
|
-
this.timestamp = timestamp;
|
178
|
-
this.meta.Timestamp = MetricsContext.resolveMetaTimestamp(timestamp);
|
179
|
-
this.defaultDimensions = defaultDimensions || {};
|
180
|
-
if (shouldUseDefaultDimensions != void 0) {
|
181
|
-
this.shouldUseDefaultDimensions = shouldUseDefaultDimensions;
|
182
|
-
}
|
183
|
-
}
|
184
|
-
static empty() {
|
185
|
-
return new MetricsContext();
|
186
|
-
}
|
187
|
-
static resolveMetaTimestamp(timestamp) {
|
188
|
-
if (timestamp instanceof Date) {
|
189
|
-
return timestamp.getTime();
|
190
|
-
} else if (timestamp) {
|
191
|
-
return timestamp;
|
192
|
-
} else {
|
193
|
-
return Date.now();
|
194
|
-
}
|
195
|
-
}
|
196
|
-
setNamespace(value) {
|
197
|
-
this.namespace = value;
|
198
|
-
}
|
199
|
-
setProperty(key, value) {
|
200
|
-
this.properties[key] = value;
|
201
|
-
}
|
202
|
-
setTimestamp(timestamp) {
|
203
|
-
this.timestamp = timestamp;
|
204
|
-
this.meta.Timestamp = MetricsContext.resolveMetaTimestamp(timestamp);
|
205
|
-
}
|
206
|
-
setDefaultDimensions(dimensions) {
|
207
|
-
Logger_1.LOG(`Received default dimensions`, dimensions);
|
208
|
-
this.defaultDimensions = dimensions;
|
209
|
-
}
|
210
|
-
putDimensions(incomingDimensionSet) {
|
211
|
-
if (this.dimensions.length === 0) {
|
212
|
-
this.dimensions.push(incomingDimensionSet);
|
213
|
-
return;
|
214
|
-
}
|
215
|
-
for (let i = 0; i < this.dimensions.length; i++) {
|
216
|
-
const existingDimensionSet = this.dimensions[i];
|
217
|
-
const existingDimensionSetKeys = Object.keys(existingDimensionSet);
|
218
|
-
const incomingDimensionSetKeys = Object.keys(incomingDimensionSet);
|
219
|
-
if (existingDimensionSetKeys.length !== incomingDimensionSetKeys.length) {
|
220
|
-
this.dimensions.push(incomingDimensionSet);
|
221
|
-
return;
|
222
|
-
}
|
223
|
-
for (let j = 0; j < existingDimensionSetKeys.length; j++) {
|
224
|
-
if (!incomingDimensionSetKeys.includes(existingDimensionSetKeys[j])) {
|
225
|
-
this.dimensions.push(incomingDimensionSet);
|
226
|
-
return;
|
227
|
-
}
|
228
|
-
}
|
229
|
-
}
|
230
|
-
}
|
231
|
-
setDimensions(dimensionSets) {
|
232
|
-
this.shouldUseDefaultDimensions = false;
|
233
|
-
this.dimensions = dimensionSets;
|
234
|
-
}
|
235
|
-
getDimensions() {
|
236
|
-
if (this.shouldUseDefaultDimensions === false) {
|
237
|
-
return this.dimensions;
|
238
|
-
}
|
239
|
-
if (Object.keys(this.defaultDimensions).length === 0) {
|
240
|
-
return this.dimensions;
|
241
|
-
}
|
242
|
-
if (this.dimensions.length === 0) {
|
243
|
-
return [this.defaultDimensions];
|
244
|
-
}
|
245
|
-
return this.dimensions.map((custom) => {
|
246
|
-
return Object.assign(Object.assign({}, this.defaultDimensions), custom);
|
247
|
-
});
|
248
|
-
}
|
249
|
-
putMetric(key, value, unit) {
|
250
|
-
const currentMetric = this.metrics.get(key);
|
251
|
-
if (currentMetric) {
|
252
|
-
currentMetric.addValue(value);
|
253
|
-
} else {
|
254
|
-
this.metrics.set(key, new MetricValues_1.MetricValues(value, unit));
|
255
|
-
}
|
256
|
-
}
|
257
|
-
createCopyWithContext() {
|
258
|
-
return new MetricsContext(this.namespace, Object.assign({}, this.properties), Object.assign([], this.dimensions), this.defaultDimensions, this.shouldUseDefaultDimensions, this.timestamp);
|
259
|
-
}
|
260
|
-
};
|
261
|
-
exports.MetricsContext = MetricsContext;
|
262
|
-
}
|
263
|
-
});
|
264
|
-
|
265
|
-
// node_modules/aws-embedded-metrics/lib/logger/MetricsLogger.js
|
266
|
-
var require_MetricsLogger = __commonJS({
|
267
|
-
"node_modules/aws-embedded-metrics/lib/logger/MetricsLogger.js"(exports) {
|
268
|
-
"use strict";
|
269
|
-
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
270
|
-
function adopt(value) {
|
271
|
-
return value instanceof P ? value : new P(function(resolve) {
|
272
|
-
resolve(value);
|
273
|
-
});
|
274
|
-
}
|
275
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
276
|
-
function fulfilled(value) {
|
277
|
-
try {
|
278
|
-
step(generator.next(value));
|
279
|
-
} catch (e) {
|
280
|
-
reject(e);
|
281
|
-
}
|
282
|
-
}
|
283
|
-
function rejected(value) {
|
284
|
-
try {
|
285
|
-
step(generator["throw"](value));
|
286
|
-
} catch (e) {
|
287
|
-
reject(e);
|
288
|
-
}
|
289
|
-
}
|
290
|
-
function step(result) {
|
291
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
292
|
-
}
|
293
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
294
|
-
});
|
295
|
-
};
|
296
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
297
|
-
var Configuration_1 = require_Configuration();
|
298
|
-
var MetricsContext_1 = require_MetricsContext();
|
299
|
-
var MetricsLogger = class {
|
300
|
-
constructor(resolveEnvironment, context) {
|
301
|
-
this.configureContextForEnvironment = (context2, environment) => {
|
302
|
-
const defaultDimensions = {
|
303
|
-
LogGroup: environment.getLogGroupName(),
|
304
|
-
ServiceName: Configuration_1.default.serviceName || environment.getName(),
|
305
|
-
ServiceType: Configuration_1.default.serviceType || environment.getType()
|
306
|
-
};
|
307
|
-
context2.setDefaultDimensions(defaultDimensions);
|
308
|
-
environment.configureContext(context2);
|
309
|
-
};
|
310
|
-
this.resolveEnvironment = resolveEnvironment;
|
311
|
-
this.context = context || MetricsContext_1.MetricsContext.empty();
|
312
|
-
}
|
313
|
-
flush() {
|
314
|
-
return __awaiter(this, void 0, void 0, function* () {
|
315
|
-
const environment = yield this.resolveEnvironment();
|
316
|
-
this.configureContextForEnvironment(this.context, environment);
|
317
|
-
const sink = environment.getSink();
|
318
|
-
yield sink.accept(this.context);
|
319
|
-
this.context = this.context.createCopyWithContext();
|
320
|
-
});
|
321
|
-
}
|
322
|
-
setProperty(key, value) {
|
323
|
-
this.context.setProperty(key, value);
|
324
|
-
return this;
|
325
|
-
}
|
326
|
-
putDimensions(dimensions) {
|
327
|
-
this.context.putDimensions(dimensions);
|
328
|
-
return this;
|
329
|
-
}
|
330
|
-
setDimensions(...dimensionSets) {
|
331
|
-
this.context.setDimensions(dimensionSets);
|
332
|
-
return this;
|
333
|
-
}
|
334
|
-
putMetric(key, value, unit) {
|
335
|
-
this.context.putMetric(key, value, unit);
|
336
|
-
return this;
|
337
|
-
}
|
338
|
-
setNamespace(value) {
|
339
|
-
this.context.setNamespace(value);
|
340
|
-
return this;
|
341
|
-
}
|
342
|
-
setTimestamp(timestamp) {
|
343
|
-
this.context.setTimestamp(timestamp);
|
344
|
-
return this;
|
345
|
-
}
|
346
|
-
new() {
|
347
|
-
return new MetricsLogger(this.resolveEnvironment, this.context.createCopyWithContext());
|
348
|
-
}
|
349
|
-
};
|
350
|
-
exports.MetricsLogger = MetricsLogger;
|
351
|
-
}
|
352
|
-
});
|
353
|
-
|
354
|
-
// node_modules/aws-embedded-metrics/lib/serializers/LogSerializer.js
|
355
|
-
var require_LogSerializer = __commonJS({
|
356
|
-
"node_modules/aws-embedded-metrics/lib/serializers/LogSerializer.js"(exports) {
|
357
|
-
"use strict";
|
358
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
359
|
-
var Constants_1 = require_Constants();
|
360
|
-
var LogSerializer = class {
|
361
|
-
serialize(context) {
|
362
|
-
const dimensionKeys = [];
|
363
|
-
let dimensionProperties = {};
|
364
|
-
context.getDimensions().forEach((d) => {
|
365
|
-
const keys = Object.keys(d).slice(0, Constants_1.Constants.MAX_DIMENSIONS);
|
366
|
-
dimensionKeys.push(keys);
|
367
|
-
dimensionProperties = Object.assign(Object.assign({}, dimensionProperties), d);
|
368
|
-
});
|
369
|
-
const createBody = () => {
|
370
|
-
return Object.assign(Object.assign(Object.assign({}, dimensionProperties), context.properties), { _aws: Object.assign(Object.assign({}, context.meta), { CloudWatchMetrics: [
|
371
|
-
{
|
372
|
-
Dimensions: dimensionKeys,
|
373
|
-
Metrics: [],
|
374
|
-
Namespace: context.namespace
|
375
|
-
}
|
376
|
-
] }) });
|
377
|
-
};
|
378
|
-
const eventBatches = [];
|
379
|
-
let currentBody = createBody();
|
380
|
-
const currentMetricsInBody = () => currentBody._aws.CloudWatchMetrics[0].Metrics.length;
|
381
|
-
const shouldSerialize = () => currentMetricsInBody() === Constants_1.Constants.MAX_METRICS_PER_EVENT;
|
382
|
-
const serializeCurrentBody = () => {
|
383
|
-
eventBatches.push(JSON.stringify(currentBody));
|
384
|
-
currentBody = createBody();
|
385
|
-
};
|
386
|
-
for (const [key, metric] of context.metrics) {
|
387
|
-
const metricValue = metric.values.length === 1 ? metric.values[0] : metric.values;
|
388
|
-
currentBody[key] = metricValue;
|
389
|
-
currentBody._aws.CloudWatchMetrics[0].Metrics.push({ Name: key, Unit: metric.unit });
|
390
|
-
if (shouldSerialize()) {
|
391
|
-
serializeCurrentBody();
|
392
|
-
}
|
393
|
-
}
|
394
|
-
if (eventBatches.length === 0 || currentMetricsInBody() > 0) {
|
395
|
-
serializeCurrentBody();
|
396
|
-
}
|
397
|
-
return eventBatches;
|
398
|
-
}
|
399
|
-
};
|
400
|
-
exports.LogSerializer = LogSerializer;
|
401
|
-
}
|
402
|
-
});
|
403
|
-
|
404
|
-
// node_modules/aws-embedded-metrics/lib/sinks/ConsoleSink.js
|
405
|
-
var require_ConsoleSink = __commonJS({
|
406
|
-
"node_modules/aws-embedded-metrics/lib/sinks/ConsoleSink.js"(exports) {
|
407
|
-
"use strict";
|
408
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
409
|
-
var LogSerializer_1 = require_LogSerializer();
|
410
|
-
var ConsoleSink = class {
|
411
|
-
constructor(serializer) {
|
412
|
-
this.name = "ConsoleSink";
|
413
|
-
this.serializer = serializer || new LogSerializer_1.LogSerializer();
|
414
|
-
}
|
415
|
-
accept(context) {
|
416
|
-
const events = this.serializer.serialize(context);
|
417
|
-
events.forEach((event) => console.log(event));
|
418
|
-
return Promise.resolve();
|
419
|
-
}
|
420
|
-
};
|
421
|
-
exports.ConsoleSink = ConsoleSink;
|
422
|
-
}
|
423
|
-
});
|
424
|
-
|
425
|
-
// node_modules/aws-embedded-metrics/lib/sinks/connections/TcpClient.js
|
426
|
-
var require_TcpClient = __commonJS({
|
427
|
-
"node_modules/aws-embedded-metrics/lib/sinks/connections/TcpClient.js"(exports) {
|
428
|
-
"use strict";
|
429
|
-
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
430
|
-
function adopt(value) {
|
431
|
-
return value instanceof P ? value : new P(function(resolve) {
|
432
|
-
resolve(value);
|
433
|
-
});
|
434
|
-
}
|
435
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
436
|
-
function fulfilled(value) {
|
437
|
-
try {
|
438
|
-
step(generator.next(value));
|
439
|
-
} catch (e) {
|
440
|
-
reject(e);
|
441
|
-
}
|
442
|
-
}
|
443
|
-
function rejected(value) {
|
444
|
-
try {
|
445
|
-
step(generator["throw"](value));
|
446
|
-
} catch (e) {
|
447
|
-
reject(e);
|
448
|
-
}
|
449
|
-
}
|
450
|
-
function step(result) {
|
451
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
452
|
-
}
|
453
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
454
|
-
});
|
455
|
-
};
|
456
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
457
|
-
var net = require("net");
|
458
|
-
var Logger_1 = require_Logger();
|
459
|
-
var TcpClient = class {
|
460
|
-
constructor(endpoint) {
|
461
|
-
this.endpoint = endpoint;
|
462
|
-
this.socket = new net.Socket({ allowHalfOpen: true, writable: false }).setEncoding("utf8").setKeepAlive(true).setTimeout(5e3).on("timeout", () => this.disconnect("idle timeout")).on("end", () => this.disconnect("end")).on("data", (data) => Logger_1.LOG("TcpClient received data.", data));
|
463
|
-
}
|
464
|
-
warmup() {
|
465
|
-
return __awaiter(this, void 0, void 0, function* () {
|
466
|
-
try {
|
467
|
-
yield this.establishConnection();
|
468
|
-
} catch (err) {
|
469
|
-
Logger_1.LOG("Failed to connect", err);
|
470
|
-
}
|
471
|
-
});
|
472
|
-
}
|
473
|
-
sendMessage(message) {
|
474
|
-
return __awaiter(this, void 0, void 0, function* () {
|
475
|
-
yield this.waitForOpenConnection();
|
476
|
-
yield new Promise((resolve, reject) => {
|
477
|
-
const onSendError = (err) => {
|
478
|
-
Logger_1.LOG("Failed to write", err);
|
479
|
-
reject(err);
|
480
|
-
};
|
481
|
-
const wasFlushedToKernel = this.socket.write(message, (err) => {
|
482
|
-
if (!err) {
|
483
|
-
Logger_1.LOG("Write succeeded");
|
484
|
-
resolve();
|
485
|
-
} else {
|
486
|
-
onSendError(err);
|
487
|
-
}
|
488
|
-
});
|
489
|
-
if (!wasFlushedToKernel) {
|
490
|
-
Logger_1.LOG("TcpClient data was not flushed to kernel buffer and was queued in memory.");
|
491
|
-
}
|
492
|
-
});
|
493
|
-
});
|
494
|
-
}
|
495
|
-
disconnect(eventName) {
|
496
|
-
Logger_1.LOG("TcpClient disconnected due to:", eventName);
|
497
|
-
this.socket.removeAllListeners();
|
498
|
-
this.socket.destroy();
|
499
|
-
this.socket.unref();
|
500
|
-
}
|
501
|
-
waitForOpenConnection() {
|
502
|
-
return __awaiter(this, void 0, void 0, function* () {
|
503
|
-
if (!this.socket.writeable || this.socket.readyState !== "open") {
|
504
|
-
yield this.establishConnection();
|
505
|
-
}
|
506
|
-
});
|
507
|
-
}
|
508
|
-
establishConnection() {
|
509
|
-
return __awaiter(this, void 0, void 0, function* () {
|
510
|
-
yield new Promise((resolve, reject) => {
|
511
|
-
const onError = (e) => {
|
512
|
-
if (e.message.includes("EISCONN")) {
|
513
|
-
resolve();
|
514
|
-
return;
|
515
|
-
}
|
516
|
-
Logger_1.LOG("TCP Client received error", e);
|
517
|
-
this.disconnect(e.message);
|
518
|
-
reject(e);
|
519
|
-
};
|
520
|
-
const onConnect = () => {
|
521
|
-
this.socket.removeListener("error", onError);
|
522
|
-
Logger_1.LOG("TcpClient connected.", this.endpoint);
|
523
|
-
resolve();
|
524
|
-
};
|
525
|
-
switch (this.socket.readyState) {
|
526
|
-
case "open":
|
527
|
-
resolve();
|
528
|
-
break;
|
529
|
-
case "opening":
|
530
|
-
this.socket.once("connect", onConnect);
|
531
|
-
this.socket.once("error", onError);
|
532
|
-
break;
|
533
|
-
default:
|
534
|
-
Logger_1.LOG("opening connection with socket in state: ", this.socket.readyState);
|
535
|
-
this.socket.connect(this.endpoint.port, this.endpoint.host, onConnect).once("error", onError);
|
536
|
-
break;
|
537
|
-
}
|
538
|
-
});
|
539
|
-
});
|
540
|
-
}
|
541
|
-
};
|
542
|
-
exports.TcpClient = TcpClient;
|
543
|
-
}
|
544
|
-
});
|
545
|
-
|
546
|
-
// node_modules/aws-embedded-metrics/lib/sinks/connections/UdpClient.js
|
547
|
-
var require_UdpClient = __commonJS({
|
548
|
-
"node_modules/aws-embedded-metrics/lib/sinks/connections/UdpClient.js"(exports) {
|
549
|
-
"use strict";
|
550
|
-
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
551
|
-
function adopt(value) {
|
552
|
-
return value instanceof P ? value : new P(function(resolve) {
|
553
|
-
resolve(value);
|
554
|
-
});
|
555
|
-
}
|
556
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
557
|
-
function fulfilled(value) {
|
558
|
-
try {
|
559
|
-
step(generator.next(value));
|
560
|
-
} catch (e) {
|
561
|
-
reject(e);
|
562
|
-
}
|
563
|
-
}
|
564
|
-
function rejected(value) {
|
565
|
-
try {
|
566
|
-
step(generator["throw"](value));
|
567
|
-
} catch (e) {
|
568
|
-
reject(e);
|
569
|
-
}
|
570
|
-
}
|
571
|
-
function step(result) {
|
572
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
573
|
-
}
|
574
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
575
|
-
});
|
576
|
-
};
|
577
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
578
|
-
var dgram = require("dgram");
|
579
|
-
var Logger_1 = require_Logger();
|
580
|
-
var UdpClient = class {
|
581
|
-
constructor(endpoint) {
|
582
|
-
this.endpoint = endpoint;
|
583
|
-
}
|
584
|
-
warmup() {
|
585
|
-
return Promise.resolve();
|
586
|
-
}
|
587
|
-
sendMessage(message) {
|
588
|
-
return __awaiter(this, void 0, void 0, function* () {
|
589
|
-
const client = dgram.createSocket("udp4");
|
590
|
-
client.send(message, this.endpoint.port, this.endpoint.host, (error) => {
|
591
|
-
if (error) {
|
592
|
-
Logger_1.LOG(error);
|
593
|
-
}
|
594
|
-
client.close();
|
595
|
-
});
|
596
|
-
return Promise.resolve();
|
597
|
-
});
|
598
|
-
}
|
599
|
-
};
|
600
|
-
exports.UdpClient = UdpClient;
|
601
|
-
}
|
602
|
-
});
|
603
|
-
|
604
|
-
// node_modules/aws-embedded-metrics/lib/sinks/AgentSink.js
|
605
|
-
var require_AgentSink = __commonJS({
|
606
|
-
"node_modules/aws-embedded-metrics/lib/sinks/AgentSink.js"(exports) {
|
607
|
-
"use strict";
|
608
|
-
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
609
|
-
function adopt(value) {
|
610
|
-
return value instanceof P ? value : new P(function(resolve) {
|
611
|
-
resolve(value);
|
612
|
-
});
|
613
|
-
}
|
614
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
615
|
-
function fulfilled(value) {
|
616
|
-
try {
|
617
|
-
step(generator.next(value));
|
618
|
-
} catch (e) {
|
619
|
-
reject(e);
|
620
|
-
}
|
621
|
-
}
|
622
|
-
function rejected(value) {
|
623
|
-
try {
|
624
|
-
step(generator["throw"](value));
|
625
|
-
} catch (e) {
|
626
|
-
reject(e);
|
627
|
-
}
|
628
|
-
}
|
629
|
-
function step(result) {
|
630
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
631
|
-
}
|
632
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
633
|
-
});
|
634
|
-
};
|
635
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
636
|
-
var url = require("url");
|
637
|
-
var Configuration_1 = require_Configuration();
|
638
|
-
var LogSerializer_1 = require_LogSerializer();
|
639
|
-
var Logger_1 = require_Logger();
|
640
|
-
var TcpClient_1 = require_TcpClient();
|
641
|
-
var UdpClient_1 = require_UdpClient();
|
642
|
-
var TCP = "tcp:";
|
643
|
-
var UDP = "udp:";
|
644
|
-
var defaultTcpEndpoint = {
|
645
|
-
host: "0.0.0.0",
|
646
|
-
port: 25888,
|
647
|
-
protocol: TCP
|
648
|
-
};
|
649
|
-
var parseEndpoint = (endpoint) => {
|
650
|
-
try {
|
651
|
-
if (!endpoint) {
|
652
|
-
return defaultTcpEndpoint;
|
653
|
-
}
|
654
|
-
const parsedUrl = url.parse(endpoint);
|
655
|
-
if (!parsedUrl.hostname || !parsedUrl.port || !parsedUrl.protocol) {
|
656
|
-
Logger_1.LOG(`Failed to parse the provided agent endpoint. Falling back to the default TCP endpoint.`, parsedUrl);
|
657
|
-
return defaultTcpEndpoint;
|
658
|
-
}
|
659
|
-
if (parsedUrl.protocol !== TCP && parsedUrl.protocol !== UDP) {
|
660
|
-
Logger_1.LOG(`The provided agent endpoint protocol '${parsedUrl.protocol}' is not supported. Please use TCP or UDP. Falling back to the default TCP endpoint.`, parsedUrl);
|
661
|
-
return defaultTcpEndpoint;
|
662
|
-
}
|
663
|
-
return {
|
664
|
-
host: parsedUrl.hostname,
|
665
|
-
port: Number(parsedUrl.port),
|
666
|
-
protocol: parsedUrl.protocol
|
667
|
-
};
|
668
|
-
} catch (e) {
|
669
|
-
Logger_1.LOG("Failed to parse the provided agent endpoint", e);
|
670
|
-
return defaultTcpEndpoint;
|
671
|
-
}
|
672
|
-
};
|
673
|
-
var AgentSink = class {
|
674
|
-
constructor(logGroupName, logStreamName, serializer) {
|
675
|
-
this.name = "AgentSink";
|
676
|
-
this.logGroupName = logGroupName;
|
677
|
-
this.logStreamName = logStreamName;
|
678
|
-
this.serializer = serializer || new LogSerializer_1.LogSerializer();
|
679
|
-
this.endpoint = parseEndpoint(Configuration_1.default.agentEndpoint);
|
680
|
-
this.socketClient = this.getSocketClient(this.endpoint);
|
681
|
-
Logger_1.LOG("Using socket client", this.socketClient.constructor.name);
|
682
|
-
}
|
683
|
-
accept(context) {
|
684
|
-
return __awaiter(this, void 0, void 0, function* () {
|
685
|
-
if (this.logGroupName) {
|
686
|
-
context.meta.LogGroupName = this.logGroupName;
|
687
|
-
}
|
688
|
-
if (this.logStreamName) {
|
689
|
-
context.meta.LogStreamName = this.logStreamName;
|
690
|
-
}
|
691
|
-
const events = this.serializer.serialize(context);
|
692
|
-
Logger_1.LOG(`Sending {} events to socket.`, events.length);
|
693
|
-
for (let index = 0; index < events.length; index++) {
|
694
|
-
const event = events[index];
|
695
|
-
const message = event + "\n";
|
696
|
-
const bytes = Buffer.from(message);
|
697
|
-
yield this.socketClient.sendMessage(bytes);
|
698
|
-
}
|
699
|
-
});
|
700
|
-
}
|
701
|
-
getSocketClient(endpoint) {
|
702
|
-
Logger_1.LOG("Getting socket client for connection.", endpoint);
|
703
|
-
const client = endpoint.protocol === TCP ? new TcpClient_1.TcpClient(endpoint) : new UdpClient_1.UdpClient(endpoint);
|
704
|
-
client.warmup();
|
705
|
-
return client;
|
706
|
-
}
|
707
|
-
};
|
708
|
-
exports.AgentSink = AgentSink;
|
709
|
-
}
|
710
|
-
});
|
711
|
-
|
712
|
-
// node_modules/aws-embedded-metrics/lib/environment/DefaultEnvironment.js
|
713
|
-
var require_DefaultEnvironment = __commonJS({
|
714
|
-
"node_modules/aws-embedded-metrics/lib/environment/DefaultEnvironment.js"(exports) {
|
715
|
-
"use strict";
|
716
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
717
|
-
var Configuration_1 = require_Configuration();
|
718
|
-
var AgentSink_1 = require_AgentSink();
|
719
|
-
var Logger_1 = require_Logger();
|
720
|
-
var DefaultEnvironment = class {
|
721
|
-
probe() {
|
722
|
-
return Promise.resolve(true);
|
723
|
-
}
|
724
|
-
getName() {
|
725
|
-
if (!Configuration_1.default.serviceName) {
|
726
|
-
Logger_1.LOG("Unknown ServiceName.");
|
727
|
-
return "Unknown";
|
728
|
-
}
|
729
|
-
return Configuration_1.default.serviceName;
|
730
|
-
}
|
731
|
-
getType() {
|
732
|
-
if (!Configuration_1.default.serviceType) {
|
733
|
-
Logger_1.LOG("Unknown ServiceType.");
|
734
|
-
return "Unknown";
|
735
|
-
}
|
736
|
-
return Configuration_1.default.serviceType;
|
737
|
-
}
|
738
|
-
getLogGroupName() {
|
739
|
-
if (Configuration_1.default.logGroupName === "") {
|
740
|
-
return "";
|
741
|
-
}
|
742
|
-
return Configuration_1.default.logGroupName ? Configuration_1.default.logGroupName : `${this.getName()}-metrics`;
|
743
|
-
}
|
744
|
-
configureContext() {
|
745
|
-
}
|
746
|
-
getSink() {
|
747
|
-
if (!this.sink) {
|
748
|
-
this.sink = new AgentSink_1.AgentSink(this.getLogGroupName(), Configuration_1.default.logStreamName);
|
749
|
-
}
|
750
|
-
return this.sink;
|
751
|
-
}
|
752
|
-
};
|
753
|
-
exports.DefaultEnvironment = DefaultEnvironment;
|
754
|
-
}
|
755
|
-
});
|
756
|
-
|
757
|
-
// node_modules/aws-embedded-metrics/lib/utils/Fetch.js
|
758
|
-
var require_Fetch = __commonJS({
|
759
|
-
"node_modules/aws-embedded-metrics/lib/utils/Fetch.js"(exports) {
|
760
|
-
"use strict";
|
761
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
762
|
-
var http = require("http");
|
763
|
-
var SOCKET_TIMEOUT = 1e3;
|
764
|
-
var fetch = (url) => {
|
765
|
-
return new Promise((resolve, reject) => {
|
766
|
-
const request = http.get(url, { timeout: 2e3 }, (response) => {
|
767
|
-
if (!response.statusCode) {
|
768
|
-
reject(`Received undefined response status code from '${url}'`);
|
769
|
-
return;
|
770
|
-
}
|
771
|
-
if (response.statusCode < 200 || response.statusCode > 299) {
|
772
|
-
reject(new Error("Failed to load page, status code: " + response.statusCode));
|
773
|
-
return;
|
774
|
-
}
|
775
|
-
const body = [];
|
776
|
-
let bodyBytes = 0;
|
777
|
-
response.on("data", (chunk) => {
|
778
|
-
bodyBytes += chunk.length;
|
779
|
-
body.push(chunk);
|
780
|
-
});
|
781
|
-
response.on("end", () => {
|
782
|
-
let responseString;
|
783
|
-
try {
|
784
|
-
const buffer = Buffer.concat(body, bodyBytes);
|
785
|
-
responseString = buffer.toString();
|
786
|
-
const parsedJson = JSON.parse(responseString);
|
787
|
-
resolve(parsedJson);
|
788
|
-
} catch (e) {
|
789
|
-
reject(`Failed to parse response from '${url}' as JSON. Received: ${responseString}`);
|
790
|
-
}
|
791
|
-
});
|
792
|
-
}).on("error", (err) => {
|
793
|
-
reject(err);
|
794
|
-
});
|
795
|
-
request.on("socket", (socket) => {
|
796
|
-
socket.on("timeout", () => {
|
797
|
-
request.abort();
|
798
|
-
reject(`Socket timeout while connecting to '${url}'`);
|
799
|
-
});
|
800
|
-
socket.setTimeout(SOCKET_TIMEOUT);
|
801
|
-
});
|
802
|
-
});
|
803
|
-
};
|
804
|
-
exports.fetch = fetch;
|
805
|
-
}
|
806
|
-
});
|
807
|
-
|
808
|
-
// node_modules/aws-embedded-metrics/lib/environment/ECSEnvironment.js
|
809
|
-
var require_ECSEnvironment = __commonJS({
|
810
|
-
"node_modules/aws-embedded-metrics/lib/environment/ECSEnvironment.js"(exports) {
|
811
|
-
"use strict";
|
812
|
-
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
813
|
-
function adopt(value) {
|
814
|
-
return value instanceof P ? value : new P(function(resolve) {
|
815
|
-
resolve(value);
|
816
|
-
});
|
817
|
-
}
|
818
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
819
|
-
function fulfilled(value) {
|
820
|
-
try {
|
821
|
-
step(generator.next(value));
|
822
|
-
} catch (e) {
|
823
|
-
reject(e);
|
824
|
-
}
|
825
|
-
}
|
826
|
-
function rejected(value) {
|
827
|
-
try {
|
828
|
-
step(generator["throw"](value));
|
829
|
-
} catch (e) {
|
830
|
-
reject(e);
|
831
|
-
}
|
832
|
-
}
|
833
|
-
function step(result) {
|
834
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
835
|
-
}
|
836
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
837
|
-
});
|
838
|
-
};
|
839
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
840
|
-
var Configuration_1 = require_Configuration();
|
841
|
-
var AgentSink_1 = require_AgentSink();
|
842
|
-
var Fetch_1 = require_Fetch();
|
843
|
-
var Logger_1 = require_Logger();
|
844
|
-
var os = require("os");
|
845
|
-
var Constants_1 = require_Constants();
|
846
|
-
var formatImageName = (imageName) => {
|
847
|
-
if (imageName) {
|
848
|
-
const splitImageName = imageName.split("/");
|
849
|
-
return splitImageName[splitImageName.length - 1];
|
850
|
-
}
|
851
|
-
return imageName;
|
852
|
-
};
|
853
|
-
var ECSEnvironment = class {
|
854
|
-
probe() {
|
855
|
-
return __awaiter(this, void 0, void 0, function* () {
|
856
|
-
if (!process.env.ECS_CONTAINER_METADATA_URI) {
|
857
|
-
return Promise.resolve(false);
|
858
|
-
}
|
859
|
-
if (process.env.FLUENT_HOST && !Configuration_1.default.agentEndpoint) {
|
860
|
-
this.fluentBitEndpoint = `tcp://${process.env.FLUENT_HOST}:${Constants_1.Constants.DEFAULT_AGENT_PORT}`;
|
861
|
-
Configuration_1.default.agentEndpoint = this.fluentBitEndpoint;
|
862
|
-
Logger_1.LOG(`Using FluentBit configuration. Endpoint: ${this.fluentBitEndpoint}`);
|
863
|
-
}
|
864
|
-
try {
|
865
|
-
this.metadata = yield Fetch_1.fetch(process.env.ECS_CONTAINER_METADATA_URI);
|
866
|
-
if (this.metadata) {
|
867
|
-
this.metadata.FormattedImageName = formatImageName(this.metadata.Image);
|
868
|
-
Logger_1.LOG(`Successfully collected ECS Container metadata.`);
|
869
|
-
}
|
870
|
-
} catch (e) {
|
871
|
-
Logger_1.LOG("Failed to collect ECS Container Metadata.");
|
872
|
-
Logger_1.LOG(e);
|
873
|
-
}
|
874
|
-
return true;
|
875
|
-
});
|
876
|
-
}
|
877
|
-
getName() {
|
878
|
-
var _a;
|
879
|
-
if (Configuration_1.default.serviceName) {
|
880
|
-
return Configuration_1.default.serviceName;
|
881
|
-
}
|
882
|
-
return ((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.FormattedImageName) ? this.metadata.FormattedImageName : "Unknown";
|
883
|
-
}
|
884
|
-
getType() {
|
885
|
-
return "AWS::ECS::Container";
|
886
|
-
}
|
887
|
-
getLogGroupName() {
|
888
|
-
if (this.fluentBitEndpoint) {
|
889
|
-
return "";
|
890
|
-
}
|
891
|
-
return Configuration_1.default.logGroupName || this.getName();
|
892
|
-
}
|
893
|
-
configureContext(context) {
|
894
|
-
var _a, _b, _c, _d, _e;
|
895
|
-
this.addProperty(context, "containerId", os.hostname());
|
896
|
-
this.addProperty(context, "createdAt", (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.CreatedAt);
|
897
|
-
this.addProperty(context, "startedAt", (_b = this.metadata) === null || _b === void 0 ? void 0 : _b.StartedAt);
|
898
|
-
this.addProperty(context, "image", (_c = this.metadata) === null || _c === void 0 ? void 0 : _c.Image);
|
899
|
-
this.addProperty(context, "cluster", (_d = this.metadata) === null || _d === void 0 ? void 0 : _d.Labels["com.amazonaws.ecs.cluster"]);
|
900
|
-
this.addProperty(context, "taskArn", (_e = this.metadata) === null || _e === void 0 ? void 0 : _e.Labels["com.amazonaws.ecs.task-arn"]);
|
901
|
-
if (this.fluentBitEndpoint) {
|
902
|
-
context.setDefaultDimensions({
|
903
|
-
ServiceName: Configuration_1.default.serviceName || this.getName(),
|
904
|
-
ServiceType: Configuration_1.default.serviceType || this.getType()
|
905
|
-
});
|
906
|
-
}
|
907
|
-
}
|
908
|
-
getSink() {
|
909
|
-
if (!this.sink) {
|
910
|
-
const logGroupName = this.fluentBitEndpoint ? "" : this.getLogGroupName();
|
911
|
-
this.sink = new AgentSink_1.AgentSink(logGroupName);
|
912
|
-
}
|
913
|
-
return this.sink;
|
914
|
-
}
|
915
|
-
addProperty(context, key, value) {
|
916
|
-
if (value) {
|
917
|
-
context.setProperty(key, value);
|
918
|
-
}
|
919
|
-
}
|
920
|
-
};
|
921
|
-
exports.ECSEnvironment = ECSEnvironment;
|
922
|
-
}
|
923
|
-
});
|
924
|
-
|
925
|
-
// node_modules/aws-embedded-metrics/lib/environment/EC2Environment.js
|
926
|
-
var require_EC2Environment = __commonJS({
|
927
|
-
"node_modules/aws-embedded-metrics/lib/environment/EC2Environment.js"(exports) {
|
928
|
-
"use strict";
|
929
|
-
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
930
|
-
function adopt(value) {
|
931
|
-
return value instanceof P ? value : new P(function(resolve) {
|
932
|
-
resolve(value);
|
933
|
-
});
|
934
|
-
}
|
935
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
936
|
-
function fulfilled(value) {
|
937
|
-
try {
|
938
|
-
step(generator.next(value));
|
939
|
-
} catch (e) {
|
940
|
-
reject(e);
|
941
|
-
}
|
942
|
-
}
|
943
|
-
function rejected(value) {
|
944
|
-
try {
|
945
|
-
step(generator["throw"](value));
|
946
|
-
} catch (e) {
|
947
|
-
reject(e);
|
948
|
-
}
|
949
|
-
}
|
950
|
-
function step(result) {
|
951
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
952
|
-
}
|
953
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
954
|
-
});
|
955
|
-
};
|
956
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
957
|
-
var Configuration_1 = require_Configuration();
|
958
|
-
var AgentSink_1 = require_AgentSink();
|
959
|
-
var Fetch_1 = require_Fetch();
|
960
|
-
var Logger_1 = require_Logger();
|
961
|
-
var endpoint = "http://169.254.169.254/latest/dynamic/instance-identity/document";
|
962
|
-
var EC2Environment = class {
|
963
|
-
probe() {
|
964
|
-
return __awaiter(this, void 0, void 0, function* () {
|
965
|
-
try {
|
966
|
-
this.metadata = yield Fetch_1.fetch(endpoint);
|
967
|
-
if (this.metadata) {
|
968
|
-
return true;
|
969
|
-
}
|
970
|
-
return false;
|
971
|
-
} catch (e) {
|
972
|
-
Logger_1.LOG(e);
|
973
|
-
return false;
|
974
|
-
}
|
975
|
-
});
|
976
|
-
}
|
977
|
-
getName() {
|
978
|
-
if (!Configuration_1.default.serviceName) {
|
979
|
-
Logger_1.LOG("Unknown ServiceName.");
|
980
|
-
return "Unknown";
|
981
|
-
}
|
982
|
-
return Configuration_1.default.serviceName;
|
983
|
-
}
|
984
|
-
getType() {
|
985
|
-
if (this.metadata) {
|
986
|
-
return "AWS::EC2::Instance";
|
987
|
-
}
|
988
|
-
return "Unknown";
|
989
|
-
}
|
990
|
-
getLogGroupName() {
|
991
|
-
return Configuration_1.default.logGroupName ? Configuration_1.default.logGroupName : `${this.getName()}-metrics`;
|
992
|
-
}
|
993
|
-
configureContext(context) {
|
994
|
-
if (this.metadata) {
|
995
|
-
context.setProperty("imageId", this.metadata.imageId);
|
996
|
-
context.setProperty("instanceId", this.metadata.instanceId);
|
997
|
-
context.setProperty("instanceType", this.metadata.instanceType);
|
998
|
-
context.setProperty("privateIP", this.metadata.privateIp);
|
999
|
-
context.setProperty("availabilityZone", this.metadata.availabilityZone);
|
1000
|
-
}
|
1001
|
-
}
|
1002
|
-
getSink() {
|
1003
|
-
if (!this.sink) {
|
1004
|
-
this.sink = new AgentSink_1.AgentSink(this.getLogGroupName(), Configuration_1.default.logStreamName);
|
1005
|
-
}
|
1006
|
-
return this.sink;
|
1007
|
-
}
|
1008
|
-
};
|
1009
|
-
exports.EC2Environment = EC2Environment;
|
1010
|
-
}
|
1011
|
-
});
|
1012
|
-
|
1013
|
-
// node_modules/aws-embedded-metrics/lib/environment/LambdaEnvironment.js
|
1014
|
-
var require_LambdaEnvironment = __commonJS({
|
1015
|
-
"node_modules/aws-embedded-metrics/lib/environment/LambdaEnvironment.js"(exports) {
|
1016
|
-
"use strict";
|
1017
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1018
|
-
var ConsoleSink_1 = require_ConsoleSink();
|
1019
|
-
var LambdaEnvironment = class {
|
1020
|
-
probe() {
|
1021
|
-
return Promise.resolve(process.env.AWS_LAMBDA_FUNCTION_NAME ? true : false);
|
1022
|
-
}
|
1023
|
-
getName() {
|
1024
|
-
return process.env.AWS_LAMBDA_FUNCTION_NAME || "Unknown";
|
1025
|
-
}
|
1026
|
-
getType() {
|
1027
|
-
return "AWS::Lambda::Function";
|
1028
|
-
}
|
1029
|
-
getLogGroupName() {
|
1030
|
-
return this.getName();
|
1031
|
-
}
|
1032
|
-
configureContext(context) {
|
1033
|
-
this.addProperty(context, "executionEnvironment", process.env.AWS_EXECUTION_ENV);
|
1034
|
-
this.addProperty(context, "memorySize", process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE);
|
1035
|
-
this.addProperty(context, "functionVersion", process.env.AWS_LAMBDA_FUNCTION_VERSION);
|
1036
|
-
this.addProperty(context, "logStreamId", process.env.AWS_LAMBDA_LOG_STREAM_NAME);
|
1037
|
-
const trace = this.getSampledTrace();
|
1038
|
-
if (trace) {
|
1039
|
-
this.addProperty(context, "traceId", trace);
|
1040
|
-
}
|
1041
|
-
}
|
1042
|
-
getSink() {
|
1043
|
-
if (!this.sink) {
|
1044
|
-
this.sink = new ConsoleSink_1.ConsoleSink();
|
1045
|
-
}
|
1046
|
-
return this.sink;
|
1047
|
-
}
|
1048
|
-
addProperty(context, key, value) {
|
1049
|
-
if (value) {
|
1050
|
-
context.setProperty(key, value);
|
1051
|
-
}
|
1052
|
-
}
|
1053
|
-
getSampledTrace() {
|
1054
|
-
if (process.env._X_AMZN_TRACE_ID && process.env._X_AMZN_TRACE_ID.includes("Sampled=1")) {
|
1055
|
-
return process.env._X_AMZN_TRACE_ID;
|
1056
|
-
}
|
1057
|
-
}
|
1058
|
-
};
|
1059
|
-
exports.LambdaEnvironment = LambdaEnvironment;
|
1060
|
-
}
|
1061
|
-
});
|
1062
|
-
|
1063
|
-
// node_modules/aws-embedded-metrics/lib/environment/LocalEnvironment.js
|
1064
|
-
var require_LocalEnvironment = __commonJS({
|
1065
|
-
"node_modules/aws-embedded-metrics/lib/environment/LocalEnvironment.js"(exports) {
|
1066
|
-
"use strict";
|
1067
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1068
|
-
var Configuration_1 = require_Configuration();
|
1069
|
-
var Logger_1 = require_Logger();
|
1070
|
-
var ConsoleSink_1 = require_ConsoleSink();
|
1071
|
-
var LocalEnvironment = class {
|
1072
|
-
probe() {
|
1073
|
-
return Promise.resolve(false);
|
1074
|
-
}
|
1075
|
-
getName() {
|
1076
|
-
if (!Configuration_1.default.serviceName) {
|
1077
|
-
Logger_1.LOG("Unknown ServiceName.");
|
1078
|
-
return "Unknown";
|
1079
|
-
}
|
1080
|
-
return Configuration_1.default.serviceName;
|
1081
|
-
}
|
1082
|
-
getType() {
|
1083
|
-
if (!Configuration_1.default.serviceType) {
|
1084
|
-
Logger_1.LOG("Unknown ServiceType.");
|
1085
|
-
return "Unknown";
|
1086
|
-
}
|
1087
|
-
return Configuration_1.default.serviceType;
|
1088
|
-
}
|
1089
|
-
getLogGroupName() {
|
1090
|
-
return Configuration_1.default.logGroupName ? Configuration_1.default.logGroupName : `${this.getName()}-metrics`;
|
1091
|
-
}
|
1092
|
-
configureContext() {
|
1093
|
-
}
|
1094
|
-
getSink() {
|
1095
|
-
if (!this.sink) {
|
1096
|
-
this.sink = new ConsoleSink_1.ConsoleSink();
|
1097
|
-
}
|
1098
|
-
return this.sink;
|
1099
|
-
}
|
1100
|
-
};
|
1101
|
-
exports.LocalEnvironment = LocalEnvironment;
|
1102
|
-
}
|
1103
|
-
});
|
1104
|
-
|
1105
|
-
// node_modules/aws-embedded-metrics/lib/environment/EnvironmentDetector.js
|
1106
|
-
var require_EnvironmentDetector = __commonJS({
|
1107
|
-
"node_modules/aws-embedded-metrics/lib/environment/EnvironmentDetector.js"(exports) {
|
1108
|
-
"use strict";
|
1109
|
-
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
1110
|
-
function adopt(value) {
|
1111
|
-
return value instanceof P ? value : new P(function(resolve) {
|
1112
|
-
resolve(value);
|
1113
|
-
});
|
1114
|
-
}
|
1115
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
1116
|
-
function fulfilled(value) {
|
1117
|
-
try {
|
1118
|
-
step(generator.next(value));
|
1119
|
-
} catch (e) {
|
1120
|
-
reject(e);
|
1121
|
-
}
|
1122
|
-
}
|
1123
|
-
function rejected(value) {
|
1124
|
-
try {
|
1125
|
-
step(generator["throw"](value));
|
1126
|
-
} catch (e) {
|
1127
|
-
reject(e);
|
1128
|
-
}
|
1129
|
-
}
|
1130
|
-
function step(result) {
|
1131
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
1132
|
-
}
|
1133
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
1134
|
-
});
|
1135
|
-
};
|
1136
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1137
|
-
var Logger_1 = require_Logger();
|
1138
|
-
var DefaultEnvironment_1 = require_DefaultEnvironment();
|
1139
|
-
var ECSEnvironment_1 = require_ECSEnvironment();
|
1140
|
-
var EC2Environment_1 = require_EC2Environment();
|
1141
|
-
var LambdaEnvironment_1 = require_LambdaEnvironment();
|
1142
|
-
var Configuration_1 = require_Configuration();
|
1143
|
-
var Environments_1 = require_Environments();
|
1144
|
-
var LocalEnvironment_1 = require_LocalEnvironment();
|
1145
|
-
var lambdaEnvironment = new LambdaEnvironment_1.LambdaEnvironment();
|
1146
|
-
var ecsEnvironment = new ECSEnvironment_1.ECSEnvironment();
|
1147
|
-
var ec2Environment = new EC2Environment_1.EC2Environment();
|
1148
|
-
var defaultEnvironment = new DefaultEnvironment_1.DefaultEnvironment();
|
1149
|
-
var environments = [lambdaEnvironment, ecsEnvironment, ec2Environment];
|
1150
|
-
var environment = void 0;
|
1151
|
-
var getEnvironmentFromOverride = () => {
|
1152
|
-
switch (Configuration_1.default.environmentOverride) {
|
1153
|
-
case Environments_1.default.Agent:
|
1154
|
-
return defaultEnvironment;
|
1155
|
-
case Environments_1.default.EC2:
|
1156
|
-
return ec2Environment;
|
1157
|
-
case Environments_1.default.Lambda:
|
1158
|
-
return lambdaEnvironment;
|
1159
|
-
case Environments_1.default.ECS:
|
1160
|
-
return ecsEnvironment;
|
1161
|
-
case Environments_1.default.Local:
|
1162
|
-
return new LocalEnvironment_1.LocalEnvironment();
|
1163
|
-
case Environments_1.default.Unknown:
|
1164
|
-
default:
|
1165
|
-
return void 0;
|
1166
|
-
}
|
1167
|
-
};
|
1168
|
-
var discoverEnvironment = () => __awaiter(void 0, void 0, void 0, function* () {
|
1169
|
-
Logger_1.LOG(`Discovering environment`);
|
1170
|
-
for (const envUnderTest of environments) {
|
1171
|
-
Logger_1.LOG(`Testing: ${envUnderTest.constructor.name}`);
|
1172
|
-
try {
|
1173
|
-
if (yield envUnderTest.probe()) {
|
1174
|
-
return envUnderTest;
|
1175
|
-
}
|
1176
|
-
} catch (e) {
|
1177
|
-
Logger_1.LOG(`Failed probe: ${envUnderTest.constructor.name}`);
|
1178
|
-
}
|
1179
|
-
}
|
1180
|
-
return defaultEnvironment;
|
1181
|
-
});
|
1182
|
-
var _resolveEnvironment = () => __awaiter(void 0, void 0, void 0, function* () {
|
1183
|
-
Logger_1.LOG("Resolving environment");
|
1184
|
-
if (environment) {
|
1185
|
-
return environment;
|
1186
|
-
}
|
1187
|
-
if (Configuration_1.default.environmentOverride) {
|
1188
|
-
Logger_1.LOG("Environment override supplied", Configuration_1.default.environmentOverride);
|
1189
|
-
environment = getEnvironmentFromOverride();
|
1190
|
-
if (environment) {
|
1191
|
-
return environment;
|
1192
|
-
} else {
|
1193
|
-
Logger_1.LOG("Invalid environment provided. Falling back to auto-discovery.", Configuration_1.default.environmentOverride);
|
1194
|
-
}
|
1195
|
-
}
|
1196
|
-
environment = yield discoverEnvironment();
|
1197
|
-
return environment;
|
1198
|
-
});
|
1199
|
-
var environmentPromise = _resolveEnvironment();
|
1200
|
-
var resolveEnvironment = () => __awaiter(void 0, void 0, void 0, function* () {
|
1201
|
-
return environmentPromise;
|
1202
|
-
});
|
1203
|
-
exports.resolveEnvironment = resolveEnvironment;
|
1204
|
-
var cleanResolveEnvironment = () => __awaiter(void 0, void 0, void 0, function* () {
|
1205
|
-
yield environmentPromise;
|
1206
|
-
environment = void 0;
|
1207
|
-
return yield _resolveEnvironment();
|
1208
|
-
});
|
1209
|
-
exports.cleanResolveEnvironment = cleanResolveEnvironment;
|
1210
|
-
}
|
1211
|
-
});
|
1212
|
-
|
1213
|
-
// node_modules/aws-embedded-metrics/lib/logger/MetricsLoggerFactory.js
|
1214
|
-
var require_MetricsLoggerFactory = __commonJS({
|
1215
|
-
"node_modules/aws-embedded-metrics/lib/logger/MetricsLoggerFactory.js"(exports) {
|
1216
|
-
"use strict";
|
1217
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1218
|
-
var __1 = require_lib();
|
1219
|
-
var EnvironmentDetector_1 = require_EnvironmentDetector();
|
1220
|
-
var MetricsContext_1 = require_MetricsContext();
|
1221
|
-
var createMetricsLogger = () => {
|
1222
|
-
const context = MetricsContext_1.MetricsContext.empty();
|
1223
|
-
const logger = new __1.MetricsLogger(EnvironmentDetector_1.resolveEnvironment, context);
|
1224
|
-
return logger;
|
1225
|
-
};
|
1226
|
-
exports.createMetricsLogger = createMetricsLogger;
|
1227
|
-
}
|
1228
|
-
});
|
1229
|
-
|
1230
|
-
// node_modules/aws-embedded-metrics/lib/logger/MetricScope.js
|
1231
|
-
var require_MetricScope = __commonJS({
|
1232
|
-
"node_modules/aws-embedded-metrics/lib/logger/MetricScope.js"(exports) {
|
1233
|
-
"use strict";
|
1234
|
-
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
1235
|
-
function adopt(value) {
|
1236
|
-
return value instanceof P ? value : new P(function(resolve) {
|
1237
|
-
resolve(value);
|
1238
|
-
});
|
1239
|
-
}
|
1240
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
1241
|
-
function fulfilled(value) {
|
1242
|
-
try {
|
1243
|
-
step(generator.next(value));
|
1244
|
-
} catch (e) {
|
1245
|
-
reject(e);
|
1246
|
-
}
|
1247
|
-
}
|
1248
|
-
function rejected(value) {
|
1249
|
-
try {
|
1250
|
-
step(generator["throw"](value));
|
1251
|
-
} catch (e) {
|
1252
|
-
reject(e);
|
1253
|
-
}
|
1254
|
-
}
|
1255
|
-
function step(result) {
|
1256
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
1257
|
-
}
|
1258
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
1259
|
-
});
|
1260
|
-
};
|
1261
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1262
|
-
var Logger_1 = require_Logger();
|
1263
|
-
var MetricsLoggerFactory_1 = require_MetricsLoggerFactory();
|
1264
|
-
var metricScope2 = (handler2) => {
|
1265
|
-
const wrappedHandler = (...args) => __awaiter(void 0, void 0, void 0, function* () {
|
1266
|
-
const metrics = MetricsLoggerFactory_1.createMetricsLogger();
|
1267
|
-
try {
|
1268
|
-
return yield handler2(metrics)(...args);
|
1269
|
-
} finally {
|
1270
|
-
try {
|
1271
|
-
yield metrics.flush();
|
1272
|
-
} catch (e) {
|
1273
|
-
Logger_1.LOG("Failed to flush metrics", e);
|
1274
|
-
}
|
1275
|
-
}
|
1276
|
-
});
|
1277
|
-
return wrappedHandler;
|
1278
|
-
};
|
1279
|
-
exports.metricScope = metricScope2;
|
1280
|
-
}
|
1281
|
-
});
|
1282
|
-
|
1283
|
-
// node_modules/aws-embedded-metrics/lib/logger/Unit.js
|
1284
|
-
var require_Unit = __commonJS({
|
1285
|
-
"node_modules/aws-embedded-metrics/lib/logger/Unit.js"(exports) {
|
1286
|
-
"use strict";
|
1287
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1288
|
-
var Unit2;
|
1289
|
-
(function(Unit3) {
|
1290
|
-
Unit3["Seconds"] = "Seconds";
|
1291
|
-
Unit3["Microseconds"] = "Microseconds";
|
1292
|
-
Unit3["Milliseconds"] = "Milliseconds";
|
1293
|
-
Unit3["Bytes"] = "Bytes";
|
1294
|
-
Unit3["Kilobytes"] = "Kilobytes";
|
1295
|
-
Unit3["Megabytes"] = "Megabytes";
|
1296
|
-
Unit3["Gigabytes"] = "Gigabytes";
|
1297
|
-
Unit3["Terabytes"] = "Terabytes";
|
1298
|
-
Unit3["Bits"] = "Bits";
|
1299
|
-
Unit3["Kilobits"] = "Kilobits";
|
1300
|
-
Unit3["Megabits"] = "Megabits";
|
1301
|
-
Unit3["Gigabits"] = "Gigabits";
|
1302
|
-
Unit3["Terabits"] = "Terabits";
|
1303
|
-
Unit3["Percent"] = "Percent";
|
1304
|
-
Unit3["Count"] = "Count";
|
1305
|
-
Unit3["BytesPerSecond"] = "Bytes/Second";
|
1306
|
-
Unit3["KilobytesPerSecond"] = "Kilobytes/Second";
|
1307
|
-
Unit3["MegabytesPerSecond"] = "Megabytes/Second";
|
1308
|
-
Unit3["GigabytesPerSecond"] = "Gigabytes/Second";
|
1309
|
-
Unit3["TerabytesPerSecond"] = "Terabytes/Second";
|
1310
|
-
Unit3["BitsPerSecond"] = "Bits/Second";
|
1311
|
-
Unit3["KilobitsPerSecond"] = "Kilobits/Second";
|
1312
|
-
Unit3["MegabitsPerSecond"] = "Megabits/Second";
|
1313
|
-
Unit3["GigabitsPerSecond"] = "Gigabits/Second";
|
1314
|
-
Unit3["TerabitsPerSecond"] = "Terabits/Second";
|
1315
|
-
Unit3["CountPerSecond"] = "Count/Second";
|
1316
|
-
Unit3["None"] = "None";
|
1317
|
-
})(Unit2 = exports.Unit || (exports.Unit = {}));
|
1318
|
-
}
|
1319
|
-
});
|
1320
|
-
|
1321
|
-
// node_modules/aws-embedded-metrics/lib/index.js
|
1322
|
-
var require_lib = __commonJS({
|
1323
|
-
"node_modules/aws-embedded-metrics/lib/index.js"(exports) {
|
1324
|
-
"use strict";
|
1325
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1326
|
-
var MetricsLogger_1 = require_MetricsLogger();
|
1327
|
-
exports.MetricsLogger = MetricsLogger_1.MetricsLogger;
|
1328
|
-
var ConsoleSink_1 = require_ConsoleSink();
|
1329
|
-
exports.LocalSink = ConsoleSink_1.ConsoleSink;
|
1330
|
-
var AgentSink_1 = require_AgentSink();
|
1331
|
-
exports.AgentSink = AgentSink_1.AgentSink;
|
1332
|
-
var MetricScope_1 = require_MetricScope();
|
1333
|
-
exports.metricScope = MetricScope_1.metricScope;
|
1334
|
-
var MetricsLoggerFactory_1 = require_MetricsLoggerFactory();
|
1335
|
-
exports.createMetricsLogger = MetricsLoggerFactory_1.createMetricsLogger;
|
1336
|
-
var Unit_1 = require_Unit();
|
1337
|
-
exports.Unit = Unit_1.Unit;
|
1338
|
-
var Configuration_1 = require_Configuration();
|
1339
|
-
exports.Configuration = Configuration_1.default;
|
1340
|
-
}
|
1341
|
-
});
|
1342
|
-
|
1343
|
-
// src/webapp/cache-invalidator/handler.lambda.ts
|
1344
|
-
__export(exports, {
|
1345
|
-
handler: () => handler
|
1346
|
-
});
|
1347
|
-
var import_aws_embedded_metrics = __toModule(require_lib());
|
1348
|
-
var AWS = __toModule(require("aws-sdk"));
|
1349
|
-
|
1350
|
-
// src/backend/shared/env.lambda-shared.ts
|
1351
|
-
var import_process = __toModule(require("process"));
|
1352
|
-
function requireEnv(name) {
|
1353
|
-
const result = import_process.env[name];
|
1354
|
-
if (!result) {
|
1355
|
-
throw new Error(`No value specified for required environment variable: ${name}`);
|
1356
|
-
}
|
1357
|
-
return result;
|
1358
|
-
}
|
1359
|
-
|
1360
|
-
// src/webapp/cache-invalidator/constants.ts
|
1361
|
-
var METRICS_NAMESPACE = "ConstructHub/CacheInvalidator";
|
1362
|
-
var MetricName;
|
1363
|
-
(function(MetricName2) {
|
1364
|
-
MetricName2["S3_EVENT_AGE"] = "S3EventAge";
|
1365
|
-
})(MetricName || (MetricName = {}));
|
1366
|
-
|
1367
|
-
// src/webapp/cache-invalidator/handler.lambda.ts
|
1368
|
-
var DISTRIBUTION_ID = requireEnv("DISTRIBUTION_ID");
|
1369
|
-
var PATH_PREFIX = requireEnv("PATH_PREFIX");
|
1370
|
-
async function handler(event, context) {
|
1371
|
-
console.log(`Event: ${JSON.stringify(event, null, 2)}`);
|
1372
|
-
if (event.Records.length === 0) {
|
1373
|
-
return;
|
1374
|
-
}
|
1375
|
-
await (0, import_aws_embedded_metrics.metricScope)((metrics) => () => {
|
1376
|
-
metrics.setDimensions();
|
1377
|
-
metrics.setNamespace(METRICS_NAMESPACE);
|
1378
|
-
const now = Date.now();
|
1379
|
-
for (const record of event.Records) {
|
1380
|
-
const age = now - new Date(record.eventTime).getTime();
|
1381
|
-
metrics.putMetric(MetricName.S3_EVENT_AGE, age, import_aws_embedded_metrics.Unit.Milliseconds);
|
1382
|
-
}
|
1383
|
-
})();
|
1384
|
-
const cf = new AWS.CloudFront();
|
1385
|
-
const invalidationRequest = {
|
1386
|
-
DistributionId: DISTRIBUTION_ID,
|
1387
|
-
InvalidationBatch: {
|
1388
|
-
Paths: {
|
1389
|
-
Quantity: event.Records.length,
|
1390
|
-
Items: event.Records.map((record) => `${PATH_PREFIX}${record.s3.object.key}`)
|
1391
|
-
},
|
1392
|
-
CallerReference: context.awsRequestId
|
1393
|
-
}
|
1394
|
-
};
|
1395
|
-
console.log(JSON.stringify({ invalidationRequet: invalidationRequest }));
|
1396
|
-
const invalidationResponse = cf.createInvalidation(invalidationRequest).promise();
|
1397
|
-
console.log(JSON.stringify({ invalidationResponse }));
|
1398
|
-
return invalidationResponse;
|
1399
|
-
}
|
1400
|
-
// Annotate the CommonJS export names for ESM import in node:
|
1401
|
-
0 && (module.exports = {
|
1402
|
-
handler
|
1403
|
-
});
|
1404
|
-
//# sourceMappingURL=index.js.map
|