@vtex/api 6.49.8-beta.0 → 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.
- package/lib/service/index.d.ts +1 -1
- package/lib/service/index.js +31 -5
- package/lib/service/metrics/client.d.ts +2 -0
- package/lib/service/metrics/client.js +35 -0
- package/lib/service/metrics/instruments/hostMetrics.d.ts +14 -0
- package/lib/service/metrics/instruments/hostMetrics.js +31 -0
- package/lib/service/metrics/metrics.d.ts +13 -0
- package/lib/service/metrics/metrics.js +74 -0
- package/lib/service/metrics/otelRequestMetricsMiddleware.d.ts +2 -0
- package/lib/service/metrics/otelRequestMetricsMiddleware.js +65 -0
- package/lib/service/telemetry/client.js +30 -18
- package/lib/service/worker/index.js +4 -0
- package/package.json +6 -2
package/lib/service/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const startApp: () => void
|
|
1
|
+
export declare const startApp: () => Promise<void>;
|
|
2
2
|
export { appPath } from './loaders';
|
package/lib/service/index.js
CHANGED
|
@@ -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
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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) {
|
|
@@ -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,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;
|
|
@@ -3,12 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
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");
|
|
6
8
|
const CLIENT_NAME = constants_1.APP.NAME || 'node-vtex-api';
|
|
7
9
|
const APPLICATION_ID = constants_1.APP.ID || 'vtex-io-app';
|
|
8
10
|
const EXPORTER_OTLP_ENDPOINT = process.env.EXPORTER_OTLP_ENDPOINT;
|
|
9
11
|
class TelemetryClientSingleton {
|
|
10
12
|
constructor() {
|
|
11
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
|
+
});
|
|
12
32
|
}
|
|
13
33
|
static getInstance() {
|
|
14
34
|
if (!TelemetryClientSingleton.instance) {
|
|
@@ -24,26 +44,18 @@ class TelemetryClientSingleton {
|
|
|
24
44
|
'environment': process.env.VTEX_WORKSPACE || 'development',
|
|
25
45
|
},
|
|
26
46
|
});
|
|
27
|
-
const tracesClient = await
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const metricsClient = await telemetryClient.newMetricsClient({
|
|
33
|
-
exporter: diagnostics_nodejs_1.Exporters.CreateExporter(diagnostics_nodejs_1.Exporters.CreateMetricsExporterConfig({
|
|
34
|
-
endpoint: EXPORTER_OTLP_ENDPOINT,
|
|
35
|
-
interval: 5,
|
|
36
|
-
timeoutSeconds: 5,
|
|
37
|
-
}), 'otlp'),
|
|
38
|
-
});
|
|
39
|
-
const logsClient = await telemetryClient.newLogsClient({
|
|
40
|
-
exporter: diagnostics_nodejs_1.Exporters.CreateExporter(diagnostics_nodejs_1.Exporters.CreateLogsExporterConfig({
|
|
41
|
-
endpoint: EXPORTER_OTLP_ENDPOINT,
|
|
42
|
-
}), 'otlp'),
|
|
43
|
-
loggerName: `node-vtex-api-${APPLICATION_ID}`,
|
|
44
|
-
});
|
|
47
|
+
const [tracesClient, metricsClient, logsClient] = await Promise.all([
|
|
48
|
+
this.initializeTracesClient(telemetryClient),
|
|
49
|
+
this.initializeMetricsClient(telemetryClient),
|
|
50
|
+
this.initializeLogsClient(telemetryClient),
|
|
51
|
+
]);
|
|
45
52
|
const instrumentations = [
|
|
46
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
|
+
}),
|
|
47
59
|
];
|
|
48
60
|
telemetryClient.registerInstrumentations(instrumentations);
|
|
49
61
|
const clients = {
|
|
@@ -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.
|
|
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,6 +47,10 @@
|
|
|
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
56
|
"@vtex/diagnostics-nodejs": "0.1.0-io-beta.19",
|
|
@@ -55,7 +59,7 @@
|
|
|
55
59
|
"agentkeepalive": "^4.0.2",
|
|
56
60
|
"apollo-server-errors": "^2.2.1",
|
|
57
61
|
"archiver": "^3.0.0",
|
|
58
|
-
"axios": "^
|
|
62
|
+
"axios": "^0.21.1",
|
|
59
63
|
"axios-retry": "^3.1.2",
|
|
60
64
|
"bluebird": "^3.5.4",
|
|
61
65
|
"chalk": "^2.4.2",
|