@application-kit/observability 0.5.0 → 0.6.0
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/CHANGELOG.md +15 -0
- package/README.md +4 -0
- package/dist/cjs/logging/fastify-request-id.d.ts +13 -0
- package/dist/cjs/logging/fastify-request-id.js +13 -0
- package/dist/cjs/logging/index.d.ts +1 -0
- package/dist/cjs/logging/index.js +1 -0
- package/dist/esm/logging/fastify-request-id.d.ts +13 -0
- package/dist/esm/logging/fastify-request-id.js +10 -0
- package/dist/esm/logging/index.d.ts +1 -0
- package/dist/esm/logging/index.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @application-kit/observability
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- aed5baf: Вход `/logging`: `fastifyRequestId` — корреляция запроса для Fastify одним объектом, `genReqId` адаптера
|
|
8
|
+
(`resolveRequestId`) и хук `onRequest`, который отвечает заголовком `x-request-id` со значением `resolveSupportId` на
|
|
9
|
+
каждый запрос, включая 404 и ошибки парсинга тела. Тип хука структурный: `fastify` входу не нужен.
|
|
10
|
+
|
|
11
|
+
## 0.5.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [7d0253e]
|
|
16
|
+
- @application-kit/typeorm@0.4.0
|
|
17
|
+
|
|
3
18
|
## 0.5.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -97,6 +97,10 @@ export class AppModule {}
|
|
|
97
97
|
Без `resolveClientIp` заголовкам не верят — см. «IP клиента за прокси».
|
|
98
98
|
- `REQUEST_ID_HEADER` и `resolveRequestId` — `genReqId` Fastify: `x-request-id` от прокси либо свой UUID.
|
|
99
99
|
- `resolveSupportId(request)` — идентификатор для пользователя и поддержки: trace_id активного спана, вне трассы — `request.id`.
|
|
100
|
+
- `fastifyRequestId` — оба конца корреляции для Fastify одним объектом: `genReqId` адаптера и хук `onRequest`, который
|
|
101
|
+
отвечает заголовком `x-request-id` со значением `resolveSupportId` на каждый запрос, включая 404 и ошибки парсинга
|
|
102
|
+
тела. Подключает его `@application-kit/bootstrap/web`; без него — `new FastifyAdapter({ genReqId })` и
|
|
103
|
+
`addHook('onRequest', onRequest)`.
|
|
100
104
|
- `INFRASTRUCTURE_PATHS`, `isInfrastructurePath` — служебные маршруты (`/health`, `/metrics`) для тишины логов и трасс;
|
|
101
105
|
контроллеры входов `/health` и `/metrics` берут путь отсюда же.
|
|
102
106
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resolveRequestId } from './resolve-request-id.js';
|
|
2
|
+
export interface FastifyRequestIdInterface {
|
|
3
|
+
genReqId: typeof resolveRequestId;
|
|
4
|
+
onRequest: typeof replyWithRequestId;
|
|
5
|
+
}
|
|
6
|
+
interface RequestIdReplyInterface {
|
|
7
|
+
header(name: string, value: string): unknown;
|
|
8
|
+
}
|
|
9
|
+
declare const replyWithRequestId: (request: {
|
|
10
|
+
id?: string | undefined;
|
|
11
|
+
}, reply: RequestIdReplyInterface, done: () => void) => void;
|
|
12
|
+
export declare const fastifyRequestId: FastifyRequestIdInterface;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fastifyRequestId = void 0;
|
|
4
|
+
const resolve_request_id_js_1 = require("./resolve-request-id.js");
|
|
5
|
+
const resolve_support_id_js_1 = require("./resolve-support-id.js");
|
|
6
|
+
const replyWithRequestId = (request, reply, done) => {
|
|
7
|
+
reply.header(resolve_request_id_js_1.REQUEST_ID_HEADER, (0, resolve_support_id_js_1.resolveSupportId)(request));
|
|
8
|
+
done();
|
|
9
|
+
};
|
|
10
|
+
exports.fastifyRequestId = {
|
|
11
|
+
genReqId: resolve_request_id_js_1.resolveRequestId,
|
|
12
|
+
onRequest: replyWithRequestId,
|
|
13
|
+
};
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./constants.js"), exports);
|
|
18
|
+
__exportStar(require("./fastify-request-id.js"), exports);
|
|
18
19
|
__exportStar(require("./infrastructure-paths.js"), exports);
|
|
19
20
|
__exportStar(require("./logger.environment.js"), exports);
|
|
20
21
|
__exportStar(require("./observability-logger.interface.js"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resolveRequestId } from './resolve-request-id.js';
|
|
2
|
+
export interface FastifyRequestIdInterface {
|
|
3
|
+
genReqId: typeof resolveRequestId;
|
|
4
|
+
onRequest: typeof replyWithRequestId;
|
|
5
|
+
}
|
|
6
|
+
interface RequestIdReplyInterface {
|
|
7
|
+
header(name: string, value: string): unknown;
|
|
8
|
+
}
|
|
9
|
+
declare const replyWithRequestId: (request: {
|
|
10
|
+
id?: string | undefined;
|
|
11
|
+
}, reply: RequestIdReplyInterface, done: () => void) => void;
|
|
12
|
+
export declare const fastifyRequestId: FastifyRequestIdInterface;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { REQUEST_ID_HEADER, resolveRequestId } from './resolve-request-id.js';
|
|
2
|
+
import { resolveSupportId } from './resolve-support-id.js';
|
|
3
|
+
const replyWithRequestId = (request, reply, done) => {
|
|
4
|
+
reply.header(REQUEST_ID_HEADER, resolveSupportId(request));
|
|
5
|
+
done();
|
|
6
|
+
};
|
|
7
|
+
export const fastifyRequestId = {
|
|
8
|
+
genReqId: resolveRequestId,
|
|
9
|
+
onRequest: replyWithRequestId,
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@application-kit/observability",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Наблюдаемость NestJS-процесса: метрики Prometheus и RED-гистограммы, health-чеки и пробы, опции pino с request-id и trace-контекстом, логирование CQRS-шин, реальный IP клиента за прокси, трейсинг OpenTelemetry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cqrs",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"test:unit": "vitest run"
|
|
123
123
|
},
|
|
124
124
|
"dependencies": {
|
|
125
|
-
"@application-kit/typeorm": "^0.
|
|
125
|
+
"@application-kit/typeorm": "^0.4.0"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
128
|
"@nestjs/common": "^11.2.7",
|