@nexload-sdk/healthcheck-otel 2.1.0 → 3.0.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/README.md +119 -2
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,5 +1,122 @@
|
|
|
1
1
|
# @nexload-sdk/healthcheck-otel
|
|
2
2
|
|
|
3
|
-
OpenTelemetry-friendly transforms for `@nexload-sdk/healthcheck
|
|
3
|
+
**OpenTelemetry-friendly resource attribute and metric record transforms for `@nexload-sdk/healthcheck` reports.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[Documentation](https://gecut.github.io/nexload-sdk/packages/healthcheck/otel/) · [API reference](https://gecut.github.io/nexload-sdk/packages/healthcheck/otel/api/)
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@nexload-sdk/healthcheck-otel)
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
> [!IMPORTANT]
|
|
13
|
+
> A new major release is pending across the healthcheck family in `.changeset/healthcheck-major.md` (import ordering updates, no runtime behavior changes).
|
|
14
|
+
|
|
15
|
+
## Table of contents
|
|
16
|
+
|
|
17
|
+
- [Overview](#overview)
|
|
18
|
+
- [Philosophy](#philosophy)
|
|
19
|
+
- [Install](#install)
|
|
20
|
+
- [Quick start](#quick-start)
|
|
21
|
+
- [Usage](#usage)
|
|
22
|
+
- [API](#api)
|
|
23
|
+
- [Configuration](#configuration)
|
|
24
|
+
- [Runtime and compatibility](#runtime-and-compatibility)
|
|
25
|
+
- [Caveats](#caveats)
|
|
26
|
+
- [Related packages](#related-packages)
|
|
27
|
+
- [License](#license)
|
|
28
|
+
|
|
29
|
+
## Overview
|
|
30
|
+
|
|
31
|
+
`@nexload-sdk/healthcheck-otel` converts a `HealthReport` into OpenTelemetry semantic resource attributes (`toOtelResourceAttributes`) and plain metric records (`toOtelMetricRecords`). It solves exporting health check statuses, run durations, and collector metrics to OpenTelemetry pipelines without pulling `@opentelemetry/sdk-metrics` into `@nexload-sdk/healthcheck`. It is for services bridging health reports into OpenTelemetry collectors or custom OTLP exporters.
|
|
32
|
+
|
|
33
|
+
What it is not:
|
|
34
|
+
|
|
35
|
+
- Not an OpenTelemetry SDK, exporter, or OTLP network client.
|
|
36
|
+
- Not a tracer or span instrumentation library.
|
|
37
|
+
|
|
38
|
+
## Philosophy
|
|
39
|
+
|
|
40
|
+
- **Zero OTel SDK dependency:** Emits plain TypeScript objects (`OtelMetricRecord[]` and `Record<string, string | number | boolean>`) so you can feed any OpenTelemetry SDK version or custom exporter.
|
|
41
|
+
- **Numeric state encoding:** Maps `ok -> 1`, `degraded -> 0.5`, and `unhealthy -> 0` for `health.status` and `health.check.status`.
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm add @nexload-sdk/healthcheck @nexload-sdk/healthcheck-otel
|
|
47
|
+
# or
|
|
48
|
+
npm install @nexload-sdk/healthcheck @nexload-sdk/healthcheck-otel
|
|
49
|
+
# or
|
|
50
|
+
yarn add @nexload-sdk/healthcheck @nexload-sdk/healthcheck-otel
|
|
51
|
+
# or
|
|
52
|
+
bun add @nexload-sdk/healthcheck @nexload-sdk/healthcheck-otel
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
| Package | Range | Required / Optional |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| *(none)* | — | No peer dependencies (`@nexload-sdk/healthcheck` is a direct dependency) |
|
|
58
|
+
|
|
59
|
+
## Quick start
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { createHealthManager, runtimeInfoCheck } from "@nexload-sdk/healthcheck";
|
|
63
|
+
import { toOtelMetricRecords, toOtelResourceAttributes } from "@nexload-sdk/healthcheck-otel";
|
|
64
|
+
|
|
65
|
+
const health = createHealthManager({
|
|
66
|
+
service: { name: "api", version: "1.0.0" },
|
|
67
|
+
checks: [runtimeInfoCheck()],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const report = await health.run("diagnostics");
|
|
71
|
+
const resourceAttrs = toOtelResourceAttributes(report);
|
|
72
|
+
const records = toOtelMetricRecords(report);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
### Emitted resource attributes and metric records
|
|
78
|
+
|
|
79
|
+
`toOtelResourceAttributes(report)` maps `service.name`, `service.version`, `deployment.environment.name`, `service.instance.id`, `process.runtime.name`, `process.runtime.version`, `host.arch`, and `os.type` (falling back to `"unknown"` when absent).
|
|
80
|
+
|
|
81
|
+
`toOtelMetricRecords(report)` emits:
|
|
82
|
+
|
|
83
|
+
| Metric Name | Unit | Type | Source |
|
|
84
|
+
| --- | --- | --- | --- |
|
|
85
|
+
| `health.status` | `state` | `gauge` | Aggregate report status (`1`, `0.5`, `0`) |
|
|
86
|
+
| `health.run.duration_ms` | `milliseconds` | `gauge` | Total `report.durationMs` |
|
|
87
|
+
| `health.check.status` | `state` | `gauge` | Per-check status (`1`, `0.5`, `0`) |
|
|
88
|
+
| `health.check.duration_ms` | `milliseconds` | `gauge` | Per-check duration |
|
|
89
|
+
| *(collector metrics)* | `metric.unit` | `metric.type` | Every entry in `report.metrics` |
|
|
90
|
+
|
|
91
|
+
## API
|
|
92
|
+
|
|
93
|
+
### Root entry (`@nexload-sdk/healthcheck-otel`)
|
|
94
|
+
|
|
95
|
+
| Export | Kind | Summary |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `toOtelResourceAttributes` | `function` | Maps `HealthReport` service/runtime/environment fields to OTel resource attributes |
|
|
98
|
+
| `toOtelMetricRecords` | `function` | Converts report status, check results, and `report.metrics` into `OtelMetricRecord[]` |
|
|
99
|
+
| `OtelMetricRecord` | `interface` | `{ name, value, attributes, unit?, type?, observedAt }` |
|
|
100
|
+
|
|
101
|
+
## Configuration
|
|
102
|
+
|
|
103
|
+
Neither `toOtelResourceAttributes` nor `toOtelMetricRecords` takes additional configuration options beyond the `HealthReport`.
|
|
104
|
+
|
|
105
|
+
## Runtime and compatibility
|
|
106
|
+
|
|
107
|
+
- **Module format:** Dual ESM (`import`) and CJS (`require`).
|
|
108
|
+
- **Runtimes:** Pure TypeScript; runs in Node.js, Bun, Edge, and browsers.
|
|
109
|
+
|
|
110
|
+
## Caveats
|
|
111
|
+
|
|
112
|
+
> [!WARNING]
|
|
113
|
+
> `toOtelMetricRecords` exports `report.metrics` produced by metric collectors; check-local `check.metrics` remain in JSON reports. Collector `metric.labels` become OpenTelemetry attributes, so keep them low-cardinality and free of secrets, user IDs, request IDs, or raw error messages.
|
|
114
|
+
|
|
115
|
+
## Related packages
|
|
116
|
+
|
|
117
|
+
- [healthcheck](../core/README.md) — Core `HealthManager` and `MetricCollectorDefinition`
|
|
118
|
+
- [healthcheck-prometheus](../prometheus/README.md) — Prometheus and OpenMetrics text serializers
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @nexload-sdk/healthcheck-otel
|
|
1
|
+
// @nexload-sdk/healthcheck-otel v3.0.0 (build 2026-11-25T11:31:39.816Z)
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -107,7 +107,7 @@ function toOtelMetricRecords(report) {
|
|
|
107
107
|
attributes: {
|
|
108
108
|
service: report.service.name,
|
|
109
109
|
scope: report.scope,
|
|
110
|
-
...metric.labels
|
|
110
|
+
...metric.labels
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n HealthMetric,\n HealthMetricValue,\n HealthReport\n} from \"@nexload-sdk/healthcheck\";\n\nexport interface OtelMetricRecord {\n name: string\n value: HealthMetricValue\n attributes: Record<string, string | number | boolean>\n unit?: string\n type?: HealthMetric[\"type\"]\n observedAt: string\n}\n\nfunction statusValue (status: string): number {\n if (status === \"ok\") return 1;\n if (status === \"degraded\") return 0.5;\n return 0;\n}\n\nexport function toOtelResourceAttributes (report: HealthReport): Record<string, string | number | boolean> {\n return {\n \"service.name\": report.service.name,\n \"service.version\": report.service.version ?? \"unknown\",\n \"deployment.environment.name\": report.service.environment ?? report.environment?.name ?? \"unknown\",\n \"service.instance.id\": report.service.instanceId ?? \"unknown\",\n \"process.runtime.name\": report.runtime.name,\n \"process.runtime.version\": report.runtime.version ?? \"unknown\",\n \"host.arch\": report.runtime.arch ?? \"unknown\",\n \"os.type\": report.runtime.platform ?? \"unknown\",\n };\n}\n\nexport function toOtelMetricRecords (report: HealthReport): OtelMetricRecord[] {\n const records: OtelMetricRecord[] = [\n {\n name: \"health.status\",\n value: statusValue(report.status),\n unit: \"state\",\n type: \"gauge\",\n observedAt: report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n status: report.status,\n },\n },\n {\n name: \"health.run.duration_ms\",\n value: report.durationMs,\n unit: \"milliseconds\",\n type: \"gauge\",\n observedAt: report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n },\n }\n ];\n\n for (const check of report.checks) {\n records.push({\n name: \"health.check.status\",\n value: statusValue(check.status),\n unit: \"state\",\n type: \"gauge\",\n observedAt: check.observedAt,\n attributes: {\n service: report.service.name,\n scope: String(check.scope),\n check: check.name,\n status: check.status,\n critical: check.critical,\n },\n });\n records.push({\n name: \"health.check.duration_ms\",\n value: check.durationMs,\n unit: \"milliseconds\",\n type: \"gauge\",\n observedAt: check.observedAt,\n attributes: {\n service: report.service.name,\n scope: String(check.scope),\n check: check.name,\n },\n });\n }\n\n for (const metric of report.metrics) {\n records.push({\n name: metric.name,\n value: metric.value,\n unit: metric.unit,\n type: metric.type,\n observedAt: metric.observedAt ?? report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n ...
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,SAAS,YAAa,QAAwB;AAC5C,MAAI,WAAW,KAAM,QAAO;AAC5B,MAAI,WAAW,WAAY,QAAO;
|
|
4
|
+
"sourcesContent": ["import type {\n HealthMetric,\n HealthMetricValue,\n HealthReport\n} from \"@nexload-sdk/healthcheck\";\n\nexport interface OtelMetricRecord {\n name: string\n value: HealthMetricValue\n attributes: Record<string, string | number | boolean>\n unit?: string\n type?: HealthMetric[\"type\"]\n observedAt: string\n}\n\nfunction statusValue (status: string): number {\n if (status === \"ok\") return 1;\n if (status === \"degraded\") return 0.5;\n\n return 0;\n}\n\nexport function toOtelResourceAttributes (report: HealthReport): Record<string, string | number | boolean> {\n return {\n \"service.name\": report.service.name,\n \"service.version\": report.service.version ?? \"unknown\",\n \"deployment.environment.name\": report.service.environment ?? report.environment?.name ?? \"unknown\",\n \"service.instance.id\": report.service.instanceId ?? \"unknown\",\n \"process.runtime.name\": report.runtime.name,\n \"process.runtime.version\": report.runtime.version ?? \"unknown\",\n \"host.arch\": report.runtime.arch ?? \"unknown\",\n \"os.type\": report.runtime.platform ?? \"unknown\",\n };\n}\n\nexport function toOtelMetricRecords (report: HealthReport): OtelMetricRecord[] {\n const records: OtelMetricRecord[] = [\n {\n name: \"health.status\",\n value: statusValue(report.status),\n unit: \"state\",\n type: \"gauge\",\n observedAt: report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n status: report.status,\n },\n },\n {\n name: \"health.run.duration_ms\",\n value: report.durationMs,\n unit: \"milliseconds\",\n type: \"gauge\",\n observedAt: report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n },\n }\n ];\n\n for (const check of report.checks) {\n records.push({\n name: \"health.check.status\",\n value: statusValue(check.status),\n unit: \"state\",\n type: \"gauge\",\n observedAt: check.observedAt,\n attributes: {\n service: report.service.name,\n scope: String(check.scope),\n check: check.name,\n status: check.status,\n critical: check.critical,\n },\n });\n records.push({\n name: \"health.check.duration_ms\",\n value: check.durationMs,\n unit: \"milliseconds\",\n type: \"gauge\",\n observedAt: check.observedAt,\n attributes: {\n service: report.service.name,\n scope: String(check.scope),\n check: check.name,\n },\n });\n }\n\n for (const metric of report.metrics) {\n records.push({\n name: metric.name,\n value: metric.value,\n unit: metric.unit,\n type: metric.type,\n observedAt: metric.observedAt ?? report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n ...metric.labels,\n },\n });\n }\n\n return records;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,SAAS,YAAa,QAAwB;AAC5C,MAAI,WAAW,KAAM,QAAO;AAC5B,MAAI,WAAW,WAAY,QAAO;AAElC,SAAO;AACT;AAEO,SAAS,yBAA0B,QAAiE;AAtB3G;AAuBE,SAAO;AAAA,IACL,gBAAgB,OAAO,QAAQ;AAAA,IAC/B,mBAAmB,OAAO,QAAQ,WAAW;AAAA,IAC7C,+BAA+B,OAAO,QAAQ,iBAAe,YAAO,gBAAP,mBAAoB,SAAQ;AAAA,IACzF,uBAAuB,OAAO,QAAQ,cAAc;AAAA,IACpD,wBAAwB,OAAO,QAAQ;AAAA,IACvC,2BAA2B,OAAO,QAAQ,WAAW;AAAA,IACrD,aAAa,OAAO,QAAQ,QAAQ;AAAA,IACpC,WAAW,OAAO,QAAQ,YAAY;AAAA,EACxC;AACF;AAEO,SAAS,oBAAqB,QAA0C;AAC7E,QAAM,UAA8B;AAAA,IAClC;AAAA,MACE,MAAM;AAAA,MACN,OAAO,YAAY,OAAO,MAAM;AAAA,MAChC,MAAM;AAAA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GAAG,OAAO;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,iBAAiB,CAAA;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;IACrD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;CACnB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,iBAAiB,CAAA;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;IACrD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;CACnB;AASD,wBAAgB,wBAAwB,CAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAWzG;AAED,wBAAgB,mBAAmB,CAAE,MAAM,EAAE,YAAY,GAAG,gBAAgB,EAAE,CAwE7E"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @nexload-sdk/healthcheck-otel
|
|
1
|
+
// @nexload-sdk/healthcheck-otel v3.0.0 (build 2026-11-25T11:31:38.587Z)
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
function statusValue(status) {
|
|
@@ -82,7 +82,7 @@ function toOtelMetricRecords(report) {
|
|
|
82
82
|
attributes: {
|
|
83
83
|
service: report.service.name,
|
|
84
84
|
scope: report.scope,
|
|
85
|
-
...metric.labels
|
|
85
|
+
...metric.labels
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n HealthMetric,\n HealthMetricValue,\n HealthReport\n} from \"@nexload-sdk/healthcheck\";\n\nexport interface OtelMetricRecord {\n name: string\n value: HealthMetricValue\n attributes: Record<string, string | number | boolean>\n unit?: string\n type?: HealthMetric[\"type\"]\n observedAt: string\n}\n\nfunction statusValue (status: string): number {\n if (status === \"ok\") return 1;\n if (status === \"degraded\") return 0.5;\n return 0;\n}\n\nexport function toOtelResourceAttributes (report: HealthReport): Record<string, string | number | boolean> {\n return {\n \"service.name\": report.service.name,\n \"service.version\": report.service.version ?? \"unknown\",\n \"deployment.environment.name\": report.service.environment ?? report.environment?.name ?? \"unknown\",\n \"service.instance.id\": report.service.instanceId ?? \"unknown\",\n \"process.runtime.name\": report.runtime.name,\n \"process.runtime.version\": report.runtime.version ?? \"unknown\",\n \"host.arch\": report.runtime.arch ?? \"unknown\",\n \"os.type\": report.runtime.platform ?? \"unknown\",\n };\n}\n\nexport function toOtelMetricRecords (report: HealthReport): OtelMetricRecord[] {\n const records: OtelMetricRecord[] = [\n {\n name: \"health.status\",\n value: statusValue(report.status),\n unit: \"state\",\n type: \"gauge\",\n observedAt: report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n status: report.status,\n },\n },\n {\n name: \"health.run.duration_ms\",\n value: report.durationMs,\n unit: \"milliseconds\",\n type: \"gauge\",\n observedAt: report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n },\n }\n ];\n\n for (const check of report.checks) {\n records.push({\n name: \"health.check.status\",\n value: statusValue(check.status),\n unit: \"state\",\n type: \"gauge\",\n observedAt: check.observedAt,\n attributes: {\n service: report.service.name,\n scope: String(check.scope),\n check: check.name,\n status: check.status,\n critical: check.critical,\n },\n });\n records.push({\n name: \"health.check.duration_ms\",\n value: check.durationMs,\n unit: \"milliseconds\",\n type: \"gauge\",\n observedAt: check.observedAt,\n attributes: {\n service: report.service.name,\n scope: String(check.scope),\n check: check.name,\n },\n });\n }\n\n for (const metric of report.metrics) {\n records.push({\n name: metric.name,\n value: metric.value,\n unit: metric.unit,\n type: metric.type,\n observedAt: metric.observedAt ?? report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n ...
|
|
5
|
-
"mappings": ";;;AAeA,SAAS,YAAa,QAAwB;AAC5C,MAAI,WAAW,KAAM,QAAO;AAC5B,MAAI,WAAW,WAAY,QAAO;
|
|
4
|
+
"sourcesContent": ["import type {\n HealthMetric,\n HealthMetricValue,\n HealthReport\n} from \"@nexload-sdk/healthcheck\";\n\nexport interface OtelMetricRecord {\n name: string\n value: HealthMetricValue\n attributes: Record<string, string | number | boolean>\n unit?: string\n type?: HealthMetric[\"type\"]\n observedAt: string\n}\n\nfunction statusValue (status: string): number {\n if (status === \"ok\") return 1;\n if (status === \"degraded\") return 0.5;\n\n return 0;\n}\n\nexport function toOtelResourceAttributes (report: HealthReport): Record<string, string | number | boolean> {\n return {\n \"service.name\": report.service.name,\n \"service.version\": report.service.version ?? \"unknown\",\n \"deployment.environment.name\": report.service.environment ?? report.environment?.name ?? \"unknown\",\n \"service.instance.id\": report.service.instanceId ?? \"unknown\",\n \"process.runtime.name\": report.runtime.name,\n \"process.runtime.version\": report.runtime.version ?? \"unknown\",\n \"host.arch\": report.runtime.arch ?? \"unknown\",\n \"os.type\": report.runtime.platform ?? \"unknown\",\n };\n}\n\nexport function toOtelMetricRecords (report: HealthReport): OtelMetricRecord[] {\n const records: OtelMetricRecord[] = [\n {\n name: \"health.status\",\n value: statusValue(report.status),\n unit: \"state\",\n type: \"gauge\",\n observedAt: report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n status: report.status,\n },\n },\n {\n name: \"health.run.duration_ms\",\n value: report.durationMs,\n unit: \"milliseconds\",\n type: \"gauge\",\n observedAt: report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n },\n }\n ];\n\n for (const check of report.checks) {\n records.push({\n name: \"health.check.status\",\n value: statusValue(check.status),\n unit: \"state\",\n type: \"gauge\",\n observedAt: check.observedAt,\n attributes: {\n service: report.service.name,\n scope: String(check.scope),\n check: check.name,\n status: check.status,\n critical: check.critical,\n },\n });\n records.push({\n name: \"health.check.duration_ms\",\n value: check.durationMs,\n unit: \"milliseconds\",\n type: \"gauge\",\n observedAt: check.observedAt,\n attributes: {\n service: report.service.name,\n scope: String(check.scope),\n check: check.name,\n },\n });\n }\n\n for (const metric of report.metrics) {\n records.push({\n name: metric.name,\n value: metric.value,\n unit: metric.unit,\n type: metric.type,\n observedAt: metric.observedAt ?? report.observedAt,\n attributes: {\n service: report.service.name,\n scope: report.scope,\n ...metric.labels,\n },\n });\n }\n\n return records;\n}\n"],
|
|
5
|
+
"mappings": ";;;AAeA,SAAS,YAAa,QAAwB;AAC5C,MAAI,WAAW,KAAM,QAAO;AAC5B,MAAI,WAAW,WAAY,QAAO;AAElC,SAAO;AACT;AAEO,SAAS,yBAA0B,QAAiE;AACzG,SAAO;AAAA,IACL,gBAAgB,OAAO,QAAQ;AAAA,IAC/B,mBAAmB,OAAO,QAAQ,WAAW;AAAA,IAC7C,+BAA+B,OAAO,QAAQ,e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QAAQ;AAAA,QACxB,OAAO,OAAO,MAAM,KAAK;AAAA,QACzB,OAAO,MAAM;AAAA,MACf;AAAA,IACF,CAAC;AAAA,EACH;AAEA,aAAW,UAAU,OAAO,SAAS;AACnC,YAAQ,KAAK;AAAA,MACX,MAAM,OAAO;AAAA,MACb,OAAO,OAAO;AAAA,MACd,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,YAAY,OAAO,cAAc,OAAO;AAAA,MACxC,YAAY;AAAA,QACV,SAAS,OAAO,QAAQ;AAAA,QACxB,OAAO,OAAO;AAAA,QACd,GAAG,OAAO;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexload-sdk/healthcheck-otel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "OpenTelemetry-friendly transforms for @nexload-sdk/healthcheck reports.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"healthcheck",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nexload-sdk/healthcheck": "
|
|
35
|
+
"@nexload-sdk/healthcheck": "5.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^25.0.3",
|
|
39
39
|
"eslint": "^9.39.2",
|
|
40
40
|
"typescript": "5.9.3",
|
|
41
41
|
"@nexload-sdk/bundler": "4.0.1",
|
|
42
|
-
"@nexload-sdk/
|
|
43
|
-
"@nexload-sdk/
|
|
42
|
+
"@nexload-sdk/typescript-config": "5.9.3",
|
|
43
|
+
"@nexload-sdk/eslint-config": "9.39.2"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "node esbuild.config.mjs",
|