@vtex/api 7.2.2 → 7.2.3
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.
|
@@ -21,19 +21,21 @@ class Logger {
|
|
|
21
21
|
const data = message ? (0, error_1.cleanError)(message) : EMPTY_MESSAGE;
|
|
22
22
|
(0, log_1.cleanLog)(data);
|
|
23
23
|
/* tslint:disable:object-literal-sort-keys */
|
|
24
|
-
const
|
|
24
|
+
const commonLogFields = {
|
|
25
25
|
__VTEX_IO_LOG: true,
|
|
26
26
|
level,
|
|
27
|
-
[constants_1.AttributeKeys.VTEX_IO_APP_ID]: app,
|
|
28
|
-
[constants_1.AttributeKeys.VTEX_ACCOUNT_NAME]: this.account,
|
|
29
|
-
[constants_1.AttributeKeys.VTEX_IO_WORKSPACE_NAME]: this.workspace,
|
|
30
|
-
[constants_1.AttributeKeys.VTEX_IO_WORKSPACE_TYPE]: this.production ? 'production' : 'development',
|
|
31
|
-
[constants_1.AttributeKeys.VTEX_IO_APP_AUTHOR_TYPE]: constants_1.APP.IS_THIRD_PARTY() ? '3p' : '1p',
|
|
32
27
|
operationId: this.operationId,
|
|
33
28
|
requestId: this.requestId,
|
|
34
|
-
data,
|
|
35
29
|
...(((_a = this.tracingState) === null || _a === void 0 ? void 0 : _a.isTraceSampled) ? { traceId: this.tracingState.traceId } : null),
|
|
36
30
|
};
|
|
31
|
+
const inflatedLog = {
|
|
32
|
+
app,
|
|
33
|
+
account: this.account,
|
|
34
|
+
workspace: this.workspace,
|
|
35
|
+
production: this.production,
|
|
36
|
+
data,
|
|
37
|
+
...commonLogFields,
|
|
38
|
+
};
|
|
37
39
|
// Mark third-party apps logs to send to skidder
|
|
38
40
|
if (constants_1.APP.IS_THIRD_PARTY()) {
|
|
39
41
|
Object.assign(inflatedLog, {
|
|
@@ -41,31 +43,39 @@ class Logger {
|
|
|
41
43
|
'__SKIDDER_TOPIC_2': `skidder.app.${constants_1.APP.VENDOR}.${constants_1.APP.NAME}`,
|
|
42
44
|
});
|
|
43
45
|
}
|
|
46
|
+
console.log(JSON.stringify(inflatedLog));
|
|
47
|
+
const diagnosticsLog = {
|
|
48
|
+
[constants_1.AttributeKeys.VTEX_IO_APP_ID]: app,
|
|
49
|
+
[constants_1.AttributeKeys.VTEX_ACCOUNT_NAME]: this.account,
|
|
50
|
+
[constants_1.AttributeKeys.VTEX_IO_WORKSPACE_NAME]: this.workspace,
|
|
51
|
+
[constants_1.AttributeKeys.VTEX_IO_WORKSPACE_TYPE]: this.production ? 'production' : 'development',
|
|
52
|
+
[constants_1.AttributeKeys.VTEX_IO_APP_AUTHOR_TYPE]: constants_1.APP.IS_THIRD_PARTY() ? '3p' : '1p',
|
|
53
|
+
...commonLogFields,
|
|
54
|
+
};
|
|
44
55
|
if (this.logClient) {
|
|
45
56
|
try {
|
|
46
57
|
let logMessage = typeof data === 'string' ? data : JSON.stringify(data);
|
|
47
58
|
switch (level) {
|
|
48
59
|
case loggerTypes_1.LogLevel.Debug:
|
|
49
|
-
this.logClient.debug(logMessage,
|
|
60
|
+
this.logClient.debug(logMessage, diagnosticsLog);
|
|
50
61
|
break;
|
|
51
62
|
case loggerTypes_1.LogLevel.Info:
|
|
52
|
-
this.logClient.info(logMessage,
|
|
63
|
+
this.logClient.info(logMessage, diagnosticsLog);
|
|
53
64
|
break;
|
|
54
65
|
case loggerTypes_1.LogLevel.Warn:
|
|
55
|
-
this.logClient.warn(logMessage,
|
|
66
|
+
this.logClient.warn(logMessage, diagnosticsLog);
|
|
56
67
|
break;
|
|
57
68
|
case loggerTypes_1.LogLevel.Error:
|
|
58
|
-
this.logClient.error(logMessage,
|
|
69
|
+
this.logClient.error(logMessage, diagnosticsLog);
|
|
59
70
|
break;
|
|
60
71
|
default:
|
|
61
|
-
this.logClient.info(logMessage,
|
|
72
|
+
this.logClient.info(logMessage, diagnosticsLog);
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
catch (e) {
|
|
65
76
|
console.error('Error using diagnostics client for logging:', e);
|
|
66
77
|
}
|
|
67
78
|
}
|
|
68
|
-
console.log(JSON.stringify(inflatedLog));
|
|
69
79
|
};
|
|
70
80
|
this.account = ctx.account;
|
|
71
81
|
this.workspace = ctx.workspace;
|
|
@@ -41,7 +41,10 @@ const addOtelRequestMetricsMiddleware = () => {
|
|
|
41
41
|
finally {
|
|
42
42
|
const responseLength = ctx.response.length;
|
|
43
43
|
if (responseLength && instruments) {
|
|
44
|
-
instruments.responseSizes.record(responseLength, {
|
|
44
|
+
instruments.responseSizes.record(responseLength, {
|
|
45
|
+
["handler" /* RequestsMetricLabels.REQUEST_HANDLER */]: ctx.requestHandlerName,
|
|
46
|
+
["status_code" /* RequestsMetricLabels.STATUS_CODE */]: ctx.response.status,
|
|
47
|
+
});
|
|
45
48
|
}
|
|
46
49
|
if (instruments) {
|
|
47
50
|
instruments.totalRequests.add(1, {
|
|
@@ -53,6 +56,7 @@ const addOtelRequestMetricsMiddleware = () => {
|
|
|
53
56
|
if (instruments) {
|
|
54
57
|
instruments.requestTimings.record((0, utils_1.hrToMillisFloat)(process.hrtime(start)), {
|
|
55
58
|
["handler" /* RequestsMetricLabels.REQUEST_HANDLER */]: ctx.requestHandlerName,
|
|
59
|
+
["status_code" /* RequestsMetricLabels.STATUS_CODE */]: ctx.response.status,
|
|
56
60
|
});
|
|
57
61
|
instruments.concurrentRequests.subtract(1);
|
|
58
62
|
}
|