@zola_do/health 0.2.15 → 0.2.16

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/README.md CHANGED
@@ -43,6 +43,37 @@ export class AppModule {}
43
43
 
44
44
  If `@nestjs/terminus` is **not** installed, the module registers a minimal `GET /health` JSON body (`mode: 'minimal'`) so imports stay safe.
45
45
 
46
+ ### Split liveness and readiness (Kubernetes)
47
+
48
+ ```typescript
49
+ ZolaHealthModule.forRoot({
50
+ splitLivenessReadiness: true,
51
+ livenessPath: 'live', // default
52
+ readinessPath: 'ready', // default
53
+ typeorm: true,
54
+ rabbitmq: true,
55
+ })
56
+ ```
57
+
58
+ | Probe | Path (default) | Checks |
59
+ | ----- | -------------- | ------ |
60
+ | Liveness | `GET /live` | Process up (heap memory) |
61
+ | Readiness | `GET /ready` | Full dependency indicators (`typeorm`, `rabbitmq`, etc.) |
62
+
63
+ ```yaml
64
+ # kubernetes deployment excerpt
65
+ livenessProbe:
66
+ httpGet:
67
+ path: /live
68
+ port: 3000
69
+ readinessProbe:
70
+ httpGet:
71
+ path: /ready
72
+ port: 3000
73
+ ```
74
+
75
+ When `splitLivenessReadiness` is false (default), a single `GET /health` runs all configured checks.
76
+
46
77
  ### Global JWT guard
47
78
 
48
79
  Use `@ZolaHealthPublic()` on custom health routes, or rely on the built-in controller: it sets the same `allowAnonymous` metadata key as `@AllowAnonymous()` from `@zola_do/authorization`.
@@ -56,6 +87,14 @@ Use `@ZolaHealthPublic()` on custom health routes, or rely on the built-in contr
56
87
  | MinIO | `MINIO_ENDPOINT`, `MINIO_PORT`, `MINIO_USESSL` |
57
88
  | Seaweed | `AWS_ENDPOINT` |
58
89
 
90
+ ## Optional OpenTelemetry trace IDs
91
+
92
+ ```typescript
93
+ import { getActiveTraceIds } from '@zola_do/health/optional/otel';
94
+ ```
95
+
96
+ Requires optional peer `@opentelemetry/api`. Returns active `traceId` / `spanId` when an OTel SDK is installed in the app. See [docs/OBSERVABILITY.md](../../docs/OBSERVABILITY.md).
97
+
59
98
  ## License
60
99
 
61
100
  ISC
@@ -0,0 +1,4 @@
1
+ export declare function getActiveTraceIds(): {
2
+ traceId?: string;
3
+ spanId?: string;
4
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getActiveTraceIds = getActiveTraceIds;
4
+ function getActiveTraceIds() {
5
+ var _a;
6
+ try {
7
+ const api = require('@opentelemetry/api');
8
+ const span = api.trace.getActiveSpan();
9
+ const ctx = (_a = span === null || span === void 0 ? void 0 : span.spanContext) === null || _a === void 0 ? void 0 : _a.call(span);
10
+ if (!ctx) {
11
+ return {};
12
+ }
13
+ return { traceId: ctx.traceId, spanId: ctx.spanId };
14
+ }
15
+ catch (_b) {
16
+ return {};
17
+ }
18
+ }
19
+ //# sourceMappingURL=otel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.js","sourceRoot":"","sources":["../../src/optional/otel.ts"],"names":[],"mappings":";;AAIA,8CAeC;AAfD,SAAgB,iBAAiB;;IAI/B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QACvC,MAAM,GAAG,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,oDAAI,CAAC;QAClC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IACtD,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zola_do/health",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "NestJS health checks (Terminus) aligned with @zola_do TypeORM, RabbitMQ, and storage env patterns",
5
5
  "author": "zolaDO",
6
6
  "license": "ISC",
@@ -18,6 +18,11 @@
18
18
  "types": "./dist/index.d.ts",
19
19
  "require": "./dist/index.js",
20
20
  "default": "./dist/index.js"
21
+ },
22
+ "./optional/otel": {
23
+ "types": "./dist/optional/otel.d.ts",
24
+ "require": "./dist/optional/otel.js",
25
+ "default": "./dist/optional/otel.js"
21
26
  }
22
27
  },
23
28
  "files": [
@@ -31,6 +36,7 @@
31
36
  "prepublishOnly": "rimraf dist && tsc"
32
37
  },
33
38
  "peerDependencies": {
39
+ "@opentelemetry/api": "^1.0.0",
34
40
  "@nestjs/common": "^10.0.0 || ^11.0.0",
35
41
  "@nestjs/core": "^10.0.0 || ^11.0.0",
36
42
  "@nestjs/microservices": "^10.0.0 || ^11.0.0",
@@ -42,6 +48,9 @@
42
48
  "typeorm": "^0.3.0 || ^1.0.0"
43
49
  },
44
50
  "peerDependenciesMeta": {
51
+ "@opentelemetry/api": {
52
+ "optional": true
53
+ },
45
54
  "@nestjs/terminus": {
46
55
  "optional": true
47
56
  },