@vtex/api 7.2.3-beta.0 → 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.
@@ -17,21 +17,24 @@ class Logger {
17
17
  this.warn = (warning) => this.log(warning, loggerTypes_1.LogLevel.Warn);
18
18
  this.error = (error) => this.log(error, loggerTypes_1.LogLevel.Error);
19
19
  this.log = (message, level) => {
20
- var _a, _b;
20
+ var _a;
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 inflatedLog = {
24
+ const commonLogFields = {
25
25
  __VTEX_IO_LOG: true,
26
26
  level,
27
+ operationId: this.operationId,
28
+ requestId: this.requestId,
29
+ ...(((_a = this.tracingState) === null || _a === void 0 ? void 0 : _a.isTraceSampled) ? { traceId: this.tracingState.traceId } : null),
30
+ };
31
+ const inflatedLog = {
27
32
  app,
28
33
  account: this.account,
29
34
  workspace: this.workspace,
30
35
  production: this.production,
31
- operationId: this.operationId,
32
- requestId: this.requestId,
33
36
  data,
34
- ...(((_a = this.tracingState) === null || _a === void 0 ? void 0 : _a.isTraceSampled) ? { traceId: this.tracingState.traceId } : null),
37
+ ...commonLogFields,
35
38
  };
36
39
  // Mark third-party apps logs to send to skidder
37
40
  if (constants_1.APP.IS_THIRD_PARTY()) {
@@ -42,17 +45,12 @@ class Logger {
42
45
  }
43
46
  console.log(JSON.stringify(inflatedLog));
44
47
  const diagnosticsLog = {
45
- __VTEX_IO_LOG: true,
46
- level,
47
48
  [constants_1.AttributeKeys.VTEX_IO_APP_ID]: app,
48
49
  [constants_1.AttributeKeys.VTEX_ACCOUNT_NAME]: this.account,
49
50
  [constants_1.AttributeKeys.VTEX_IO_WORKSPACE_NAME]: this.workspace,
50
51
  [constants_1.AttributeKeys.VTEX_IO_WORKSPACE_TYPE]: this.production ? 'production' : 'development',
51
52
  [constants_1.AttributeKeys.VTEX_IO_APP_AUTHOR_TYPE]: constants_1.APP.IS_THIRD_PARTY() ? '3p' : '1p',
52
- operationId: this.operationId,
53
- requestId: this.requestId,
54
- data,
55
- ...(((_b = this.tracingState) === null || _b === void 0 ? void 0 : _b.isTraceSampled) ? { traceId: this.tracingState.traceId } : null),
53
+ ...commonLogFields,
56
54
  };
57
55
  if (this.logClient) {
58
56
  try {
@@ -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, { ["handler" /* RequestsMetricLabels.REQUEST_HANDLER */]: ctx.requestHandlerName });
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "7.2.3-beta.0",
3
+ "version": "7.2.3",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",