@vtex/api 6.49.8-beta.1 → 6.49.8-beta.2

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.
@@ -1,2 +1,2 @@
1
- export declare const startApp: () => void;
1
+ export declare const startApp: () => Promise<void>;
2
2
  export { appPath } from './loaders';
@@ -1,25 +1,51 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.appPath = exports.startApp = void 0;
30
+ const telemetry_1 = require("./telemetry");
7
31
  const cluster_1 = __importDefault(require("cluster"));
8
32
  const constants_1 = require("../constants");
9
33
  const loaders_1 = require("./loaders");
10
34
  const logger_1 = require("./logger");
11
- const master_1 = require("./master");
12
- const worker_1 = require("./worker");
13
- const startApp = () => {
35
+ const startApp = async () => {
36
+ await (0, telemetry_1.initializeTelemetry)();
14
37
  const serviceJSON = (0, loaders_1.getServiceJSON)();
15
38
  try {
16
39
  // if it is a master process then call setting up worker process
17
40
  if (cluster_1.default.isMaster) {
18
- (0, master_1.startMaster)(serviceJSON);
41
+ const { startMaster } = await Promise.resolve().then(() => __importStar(require('./master')));
42
+ startMaster(serviceJSON);
19
43
  }
20
44
  else {
21
45
  // to setup server configurations and share port address for incoming requests
22
- (0, worker_1.startWorker)(serviceJSON).listen(constants_1.HTTP_SERVER_PORT);
46
+ const { startWorker } = await Promise.resolve().then(() => __importStar(require('./worker')));
47
+ const app = await startWorker(serviceJSON);
48
+ app.listen(constants_1.HTTP_SERVER_PORT);
23
49
  }
24
50
  }
25
51
  catch (err) {
@@ -1,2 +1,2 @@
1
- import { LogClient } from '@vtex/diagnostics-nodejs/dist/types';
2
- export declare function getLogClient(account: string, workspace: string, appName: string): Promise<LogClient>;
1
+ import { Types } from '@vtex/diagnostics-nodejs';
2
+ export declare function getLogClient(): Promise<Types.LogClient>;
@@ -1,45 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLogClient = void 0;
4
- const diagnostics_nodejs_1 = require("@vtex/diagnostics-nodejs");
5
4
  const telemetry_1 = require("../telemetry");
6
- let logClient;
5
+ let client;
7
6
  let isInitializing = false;
8
7
  let initPromise = undefined;
9
- async function getLogClient(account, workspace, appName) {
10
- if (logClient) {
11
- return logClient;
8
+ async function getLogClient() {
9
+ if (client) {
10
+ return client;
12
11
  }
13
12
  if (initPromise) {
14
13
  return initPromise;
15
14
  }
16
15
  isInitializing = true;
17
- initPromise = initializeClient(account, workspace, appName);
16
+ initPromise = initializeClient();
18
17
  return initPromise;
19
18
  }
20
19
  exports.getLogClient = getLogClient;
21
- async function initializeClient(account, workspace, appName) {
20
+ async function initializeClient() {
22
21
  try {
23
- const telemetryClient = await (0, telemetry_1.getTelemetryClient)();
24
- const logsConfig = diagnostics_nodejs_1.Exporters.CreateLogsExporterConfig({
25
- endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
26
- path: process.env.OTEL_EXPORTER_OTLP_PATH || '/v1/logs',
27
- protocol: 'http',
28
- interval: 5,
29
- timeoutSeconds: 5,
30
- headers: { 'Content-Type': 'application/json' },
31
- });
32
- const logsExporter = diagnostics_nodejs_1.Exporters.CreateExporter(logsConfig, 'otlp');
33
- await logsExporter.initialize();
34
- const clientKey = `${account}-${workspace}-${appName}`;
35
- logClient = await telemetryClient.newLogsClient({
36
- exporter: logsExporter,
37
- loggerName: `node-vtex-api-${clientKey}`,
38
- });
39
- return logClient;
22
+ const { logsClient } = await (0, telemetry_1.initializeTelemetry)();
23
+ client = logsClient;
24
+ initPromise = undefined;
25
+ return logsClient;
40
26
  }
41
27
  catch (error) {
42
28
  console.error('Failed to initialize logs client:', error);
29
+ initPromise = undefined;
43
30
  throw error;
44
31
  }
45
32
  finally {
@@ -89,7 +89,7 @@ class Logger {
89
89
  setTimeout(() => reject(new Error('Log client initialization timeout')), constants_1.LOG_CLIENT_INIT_TIMEOUT_MS);
90
90
  });
91
91
  this.logClient = await Promise.race([
92
- (0, client_1.getLogClient)(this.account, this.workspace, constants_1.APP.NAME),
92
+ (0, client_1.getLogClient)(),
93
93
  timeoutPromise
94
94
  ]);
95
95
  return this.logClient;
@@ -0,0 +1,2 @@
1
+ import { Types } from "@vtex/diagnostics-nodejs";
2
+ export declare function getMetricClient(): Promise<Types.MetricClient>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMetricClient = void 0;
4
+ const telemetry_1 = require("../telemetry");
5
+ let client;
6
+ let isInitializing = false;
7
+ let initPromise = undefined;
8
+ async function getMetricClient() {
9
+ if (client) {
10
+ return client;
11
+ }
12
+ if (initPromise) {
13
+ return initPromise;
14
+ }
15
+ isInitializing = true;
16
+ initPromise = initializeClient();
17
+ return initPromise;
18
+ }
19
+ exports.getMetricClient = getMetricClient;
20
+ async function initializeClient() {
21
+ try {
22
+ const { metricsClient } = await (0, telemetry_1.initializeTelemetry)();
23
+ client = metricsClient;
24
+ initPromise = undefined;
25
+ return metricsClient;
26
+ }
27
+ catch (error) {
28
+ console.error('Failed to initialize metrics client:', error);
29
+ initPromise = undefined;
30
+ throw error;
31
+ }
32
+ finally {
33
+ isInitializing = false;
34
+ }
35
+ }
@@ -0,0 +1,14 @@
1
+ import { InstrumentationBase, InstrumentationConfig } from "@opentelemetry/instrumentation";
2
+ import { MeterProvider } from '@opentelemetry/api';
3
+ interface HostMetricsInstrumentationConfig extends InstrumentationConfig {
4
+ name?: string;
5
+ meterProvider?: MeterProvider;
6
+ }
7
+ export declare class HostMetricsInstrumentation extends InstrumentationBase<HostMetricsInstrumentationConfig> {
8
+ private hostMetrics?;
9
+ constructor(config?: HostMetricsInstrumentationConfig);
10
+ init(): void;
11
+ enable(): void;
12
+ disable(): void;
13
+ }
14
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HostMetricsInstrumentation = void 0;
4
+ const instrumentation_1 = require("@opentelemetry/instrumentation");
5
+ const host_metrics_1 = require("@opentelemetry/host-metrics");
6
+ class HostMetricsInstrumentation extends instrumentation_1.InstrumentationBase {
7
+ constructor(config = {}) {
8
+ const instrumentation_name = config.name || 'host-metrics-instrumentation';
9
+ const instrumentation_version = '1.0.0';
10
+ super(instrumentation_name, instrumentation_version, config);
11
+ }
12
+ init() { }
13
+ enable() {
14
+ if (!this._config.meterProvider) {
15
+ throw new Error('MeterProvider is required for HostMetricsInstrumentation');
16
+ }
17
+ this.hostMetrics = new host_metrics_1.HostMetrics({
18
+ meterProvider: this._config.meterProvider,
19
+ name: this._config.name || 'host-metrics',
20
+ });
21
+ this.hostMetrics.start();
22
+ console.debug('HostMetricsInstrumentation enabled');
23
+ }
24
+ disable() {
25
+ if (this.hostMetrics) {
26
+ this.hostMetrics = undefined;
27
+ console.debug('HostMetricsInstrumentation disabled');
28
+ }
29
+ }
30
+ }
31
+ exports.HostMetricsInstrumentation = HostMetricsInstrumentation;
@@ -0,0 +1,13 @@
1
+ import { Types } from '@vtex/diagnostics-nodejs';
2
+ export declare const enum RequestsMetricLabels {
3
+ STATUS_CODE = "status_code",
4
+ REQUEST_HANDLER = "handler"
5
+ }
6
+ export interface OtelRequestInstruments {
7
+ concurrentRequests: Types.Gauge;
8
+ requestTimings: Types.Histogram;
9
+ totalRequests: Types.Counter;
10
+ responseSizes: Types.Histogram;
11
+ abortedRequests: Types.Counter;
12
+ }
13
+ export declare const getOtelInstruments: () => Promise<OtelRequestInstruments>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOtelInstruments = void 0;
4
+ const client_1 = require("./client");
5
+ let instruments;
6
+ let initializingPromise;
7
+ const createOtelConcurrentRequestsInstrument = async () => {
8
+ const metricsClient = await (0, client_1.getMetricClient)();
9
+ return metricsClient.createGauge('io_http_requests_current', {
10
+ description: 'The current number of requests in course.',
11
+ unit: '1'
12
+ });
13
+ };
14
+ const createOtelRequestsTimingsInstrument = async () => {
15
+ const metricsClient = await (0, client_1.getMetricClient)();
16
+ return metricsClient.createHistogram('runtime_http_requests_duration_milliseconds', {
17
+ description: 'The incoming http requests total duration.',
18
+ unit: 'ms'
19
+ });
20
+ };
21
+ const createOtelTotalRequestsInstrument = async () => {
22
+ const metricsClient = await (0, client_1.getMetricClient)();
23
+ return metricsClient.createCounter('runtime_http_requests_total', {
24
+ description: 'The total number of HTTP requests.',
25
+ unit: '1'
26
+ });
27
+ };
28
+ const createOtelRequestsResponseSizesInstrument = async () => {
29
+ const metricsClient = await (0, client_1.getMetricClient)();
30
+ return metricsClient.createHistogram('runtime_http_response_size_bytes', {
31
+ description: 'The outgoing response sizes (only applicable when the response isn\'t a stream).',
32
+ unit: 'bytes'
33
+ });
34
+ };
35
+ const createOtelTotalAbortedRequestsInstrument = async () => {
36
+ const metricsClient = await (0, client_1.getMetricClient)();
37
+ return metricsClient.createCounter('runtime_http_aborted_requests_total', {
38
+ description: 'The total number of HTTP requests aborted.',
39
+ unit: '1'
40
+ });
41
+ };
42
+ const getOtelInstruments = async () => {
43
+ if (instruments) {
44
+ return instruments;
45
+ }
46
+ if (initializingPromise) {
47
+ return initializingPromise;
48
+ }
49
+ initializingPromise = initializeOtelInstruments();
50
+ try {
51
+ instruments = await initializingPromise;
52
+ return instruments;
53
+ }
54
+ finally {
55
+ initializingPromise = undefined;
56
+ }
57
+ };
58
+ exports.getOtelInstruments = getOtelInstruments;
59
+ const initializeOtelInstruments = async () => {
60
+ const [concurrentRequests, requestTimings, totalRequests, responseSizes, abortedRequests] = await Promise.all([
61
+ createOtelConcurrentRequestsInstrument(),
62
+ createOtelRequestsTimingsInstrument(),
63
+ createOtelTotalRequestsInstrument(),
64
+ createOtelRequestsResponseSizesInstrument(),
65
+ createOtelTotalAbortedRequestsInstrument()
66
+ ]);
67
+ return {
68
+ concurrentRequests,
69
+ requestTimings,
70
+ totalRequests,
71
+ responseSizes,
72
+ abortedRequests
73
+ };
74
+ };
@@ -0,0 +1,2 @@
1
+ import { ServiceContext } from '../worker/runtime/typings';
2
+ export declare const addOtelRequestMetricsMiddleware: () => (ctx: ServiceContext, next: () => Promise<void>) => Promise<void>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addOtelRequestMetricsMiddleware = void 0;
4
+ const stream_1 = require("stream");
5
+ const utils_1 = require("../../utils");
6
+ const metrics_1 = require("./metrics");
7
+ const INSTRUMENTS_INITIALIZATION_TIMEOUT = 500;
8
+ const addOtelRequestMetricsMiddleware = () => {
9
+ let instruments;
10
+ return async function addOtelRequestMetrics(ctx, next) {
11
+ if (!instruments) {
12
+ try {
13
+ instruments = await Promise.race([
14
+ (0, metrics_1.getOtelInstruments)(),
15
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout waiting for OpenTelemetry instruments initialization')), INSTRUMENTS_INITIALIZATION_TIMEOUT))
16
+ ]);
17
+ }
18
+ catch (error) {
19
+ const errorMessage = error instanceof Error ? error.message : String(error);
20
+ console.warn(`OpenTelemetry instruments not ready for request ${ctx.requestHandlerName}: ${errorMessage}`);
21
+ await next();
22
+ return;
23
+ }
24
+ }
25
+ const start = process.hrtime();
26
+ instruments.concurrentRequests.add(1);
27
+ ctx.req.once('aborted', () => {
28
+ if (instruments) {
29
+ instruments.abortedRequests.add(1, { ["handler" /* RequestsMetricLabels.REQUEST_HANDLER */]: ctx.requestHandlerName });
30
+ }
31
+ });
32
+ let responseClosed = false;
33
+ ctx.res.once('close', () => (responseClosed = true));
34
+ try {
35
+ await next();
36
+ }
37
+ finally {
38
+ const responseLength = ctx.response.length;
39
+ if (responseLength && instruments) {
40
+ instruments.responseSizes.record(responseLength, { ["handler" /* RequestsMetricLabels.REQUEST_HANDLER */]: ctx.requestHandlerName });
41
+ }
42
+ if (instruments) {
43
+ instruments.totalRequests.add(1, {
44
+ ["handler" /* RequestsMetricLabels.REQUEST_HANDLER */]: ctx.requestHandlerName,
45
+ ["status_code" /* RequestsMetricLabels.STATUS_CODE */]: ctx.response.status,
46
+ });
47
+ }
48
+ const onResFinished = () => {
49
+ if (instruments) {
50
+ instruments.requestTimings.record((0, utils_1.hrToMillisFloat)(process.hrtime(start)), {
51
+ ["handler" /* RequestsMetricLabels.REQUEST_HANDLER */]: ctx.requestHandlerName,
52
+ });
53
+ instruments.concurrentRequests.subtract(1);
54
+ }
55
+ };
56
+ if (responseClosed) {
57
+ onResFinished();
58
+ }
59
+ else {
60
+ (0, stream_1.finished)(ctx.res, onResFinished);
61
+ }
62
+ }
63
+ };
64
+ };
65
+ exports.addOtelRequestMetricsMiddleware = addOtelRequestMetricsMiddleware;
@@ -1,3 +1,9 @@
1
- import { TelemetryClient } from '@vtex/diagnostics-nodejs/dist/telemetry';
2
- export declare function getTelemetryClient(): Promise<TelemetryClient>;
3
- export declare function resetTelemetryClient(): void;
1
+ import { Logs, Metrics, Traces } from '@vtex/diagnostics-nodejs';
2
+ interface TelemetryClients {
3
+ logsClient: Logs.LogClient;
4
+ metricsClient: Metrics.MetricsClient;
5
+ tracesClient: Traces.TraceClient;
6
+ }
7
+ export declare function initializeTelemetry(): Promise<TelemetryClients>;
8
+ export declare function resetTelemetry(): void;
9
+ export {};
@@ -1,11 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resetTelemetryClient = exports.getTelemetryClient = void 0;
3
+ exports.resetTelemetry = exports.initializeTelemetry = void 0;
4
4
  const diagnostics_nodejs_1 = require("@vtex/diagnostics-nodejs");
5
5
  const constants_1 = require("../../constants");
6
+ const instrumentation_koa_1 = require("@opentelemetry/instrumentation-koa");
7
+ const hostMetrics_1 = require("../metrics/instruments/hostMetrics");
8
+ const CLIENT_NAME = constants_1.APP.NAME || 'node-vtex-api';
9
+ const APPLICATION_ID = constants_1.APP.ID || 'vtex-io-app';
10
+ const EXPORTER_OTLP_ENDPOINT = process.env.EXPORTER_OTLP_ENDPOINT;
6
11
  class TelemetryClientSingleton {
7
12
  constructor() {
8
13
  this.initializationPromise = undefined;
14
+ this.initializeTracesClient = async (telemetryClient) => await telemetryClient.newTracesClient({
15
+ exporter: diagnostics_nodejs_1.Exporters.CreateExporter(diagnostics_nodejs_1.Exporters.CreateTracesExporterConfig({
16
+ endpoint: EXPORTER_OTLP_ENDPOINT,
17
+ }), 'otlp'),
18
+ });
19
+ this.initializeMetricsClient = async (telemetryClient) => await telemetryClient.newMetricsClient({
20
+ exporter: diagnostics_nodejs_1.Exporters.CreateExporter(diagnostics_nodejs_1.Exporters.CreateMetricsExporterConfig({
21
+ endpoint: EXPORTER_OTLP_ENDPOINT,
22
+ interval: 5,
23
+ timeoutSeconds: 5,
24
+ }), 'otlp'),
25
+ });
26
+ this.initializeLogsClient = async (telemetryClient) => await telemetryClient.newLogsClient({
27
+ exporter: diagnostics_nodejs_1.Exporters.CreateExporter(diagnostics_nodejs_1.Exporters.CreateLogsExporterConfig({
28
+ endpoint: EXPORTER_OTLP_ENDPOINT,
29
+ }), 'otlp'),
30
+ loggerName: `node-vtex-api-${APPLICATION_ID}`,
31
+ });
9
32
  }
10
33
  static getInstance() {
11
34
  if (!TelemetryClientSingleton.instance) {
@@ -13,45 +36,64 @@ class TelemetryClientSingleton {
13
36
  }
14
37
  return TelemetryClientSingleton.instance;
15
38
  }
16
- async initTelemetryClient() {
39
+ async initializeTelemetryClients() {
17
40
  try {
18
- const telemetryClient = await (0, diagnostics_nodejs_1.NewTelemetryClient)('node-vtex-api', constants_1.APP.ID || 'vtex-app', {
41
+ const telemetryClient = await (0, diagnostics_nodejs_1.NewTelemetryClient)(APPLICATION_ID, CLIENT_NAME, 'node-vtex-api', {
19
42
  additionalAttrs: {
20
43
  'version': constants_1.APP.VERSION || '',
21
44
  'environment': process.env.VTEX_WORKSPACE || 'development',
22
45
  },
23
46
  });
24
- this.telemetryClient = telemetryClient;
25
- return telemetryClient;
47
+ const [tracesClient, metricsClient, logsClient] = await Promise.all([
48
+ this.initializeTracesClient(telemetryClient),
49
+ this.initializeMetricsClient(telemetryClient),
50
+ this.initializeLogsClient(telemetryClient),
51
+ ]);
52
+ const instrumentations = [
53
+ ...diagnostics_nodejs_1.Instrumentation.CommonInstrumentations.minimal(),
54
+ new instrumentation_koa_1.KoaInstrumentation(),
55
+ new hostMetrics_1.HostMetricsInstrumentation({
56
+ name: 'host-metrics-instrumentation',
57
+ meterProvider: metricsClient.provider(),
58
+ }),
59
+ ];
60
+ telemetryClient.registerInstrumentations(instrumentations);
61
+ const clients = {
62
+ logsClient,
63
+ metricsClient,
64
+ tracesClient,
65
+ };
66
+ this.telemetryClients = clients;
67
+ return clients;
26
68
  }
27
69
  catch (error) {
28
- console.error('Failed to initialize telemetry client:', error);
70
+ console.error('Failed to initialize telemetry clients:', error);
29
71
  throw error;
30
72
  }
31
73
  finally {
32
74
  this.initializationPromise = undefined;
33
75
  }
34
76
  }
35
- async getClient() {
36
- if (this.telemetryClient) {
37
- return this.telemetryClient;
77
+ async getTelemetryClients() {
78
+ if (this.telemetryClients) {
79
+ return this.telemetryClients;
38
80
  }
39
81
  if (this.initializationPromise) {
40
82
  return this.initializationPromise;
41
83
  }
42
- this.initializationPromise = this.initTelemetryClient();
84
+ this.initializationPromise = this.initializeTelemetryClients();
43
85
  return this.initializationPromise;
44
86
  }
45
87
  reset() {
46
- this.telemetryClient = undefined;
88
+ this.telemetryClients = undefined;
47
89
  this.initializationPromise = undefined;
48
90
  }
49
91
  }
50
- async function getTelemetryClient() {
51
- return TelemetryClientSingleton.getInstance().getClient();
92
+ async function initializeTelemetry() {
93
+ return TelemetryClientSingleton.getInstance().getTelemetryClients();
52
94
  }
53
- exports.getTelemetryClient = getTelemetryClient;
54
- function resetTelemetryClient() {
95
+ exports.initializeTelemetry = initializeTelemetry;
96
+ function resetTelemetry() {
55
97
  TelemetryClientSingleton.getInstance().reset();
56
98
  }
57
- exports.resetTelemetryClient = resetTelemetryClient;
99
+ exports.resetTelemetry = resetTelemetry;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.startWorker = void 0;
7
+ const diagnostics_nodejs_1 = require("@vtex/diagnostics-nodejs");
7
8
  const http_1 = require("http");
8
9
  const koa_1 = __importDefault(require("koa"));
9
10
  const koa_compress_1 = __importDefault(require("koa-compress"));
@@ -15,6 +16,7 @@ const loaders_1 = require("../loaders");
15
16
  const console_1 = require("../logger/console");
16
17
  const loggerTypes_1 = require("../logger/loggerTypes");
17
18
  const requestMetricsMiddleware_1 = require("../metrics/requestMetricsMiddleware");
19
+ const otelRequestMetricsMiddleware_1 = require("../metrics/otelRequestMetricsMiddleware");
18
20
  const TracerSingleton_1 = require("../tracing/TracerSingleton");
19
21
  const tracingMiddlewares_1 = require("../tracing/tracingMiddlewares");
20
22
  const listeners_1 = require("./listeners");
@@ -157,9 +159,11 @@ const startWorker = (serviceJSON) => {
157
159
  app.proxy = true;
158
160
  app
159
161
  .use(error_1.error)
162
+ .use(diagnostics_nodejs_1.Instrumentation.Middlewares.ContextMiddlewares.Koa.ContextPropagationMiddleware())
160
163
  .use((0, middlewares_1.prometheusLoggerMiddleware)())
161
164
  .use((0, tracingMiddlewares_1.addTracingMiddleware)(tracer))
162
165
  .use((0, requestMetricsMiddleware_1.addRequestMetricsMiddleware)())
166
+ .use((0, otelRequestMetricsMiddleware_1.addOtelRequestMetricsMiddleware)())
163
167
  .use((0, middlewares_1.addMetricsLoggerMiddleware)())
164
168
  .use((0, rateLimit_1.concurrentRateLimiter)((_a = serviceJSON === null || serviceJSON === void 0 ? void 0 : serviceJSON.rateLimitPerReplica) === null || _a === void 0 ? void 0 : _a.concurrent))
165
169
  .use((0, koa_compress_1.default)())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "6.49.8-beta.1",
3
+ "version": "6.49.8-beta.2",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -47,15 +47,19 @@
47
47
  },
48
48
  "license": "MIT",
49
49
  "dependencies": {
50
+ "@opentelemetry/api": "^1.9.0",
51
+ "@opentelemetry/host-metrics": "0.35.5",
52
+ "@opentelemetry/instrumentation": "0.57.2",
53
+ "@opentelemetry/instrumentation-koa": "0.47.1",
50
54
  "@types/koa": "^2.11.0",
51
55
  "@types/koa-compose": "^3.2.3",
52
- "@vtex/diagnostics-nodejs": "0.1.0-beta.10",
56
+ "@vtex/diagnostics-nodejs": "0.1.0-io-beta.19",
53
57
  "@vtex/node-error-report": "^0.0.3",
54
58
  "@wry/equality": "^0.1.9",
55
59
  "agentkeepalive": "^4.0.2",
56
60
  "apollo-server-errors": "^2.2.1",
57
61
  "archiver": "^3.0.0",
58
- "axios": "^1.11.0",
62
+ "axios": "^0.21.1",
59
63
  "axios-retry": "^3.1.2",
60
64
  "bluebird": "^3.5.4",
61
65
  "chalk": "^2.4.2",
@@ -124,5 +128,8 @@
124
128
  "typemoq": "^2.1.0",
125
129
  "typescript": "^4.4.4",
126
130
  "typescript-json-schema": "^0.52.0"
131
+ },
132
+ "resolutions": {
133
+ "@grpc/grpc-js": "^1.13.4"
127
134
  }
128
135
  }