Skip to content

Overview & Quick Start

OpenTelemetry Health Integration

@nexload-sdk/healthcheck-otel

v3.0.1 Released

OpenTelemetry-friendly transforms for @nexload-sdk/healthcheck reports.

Examples follow workspace source. Check pending Changesets against your installed version.

SDK dependencies: @nexload-sdk/healthcheck

@nexload-sdk/healthcheck-otel converts a @nexload-sdk/healthcheck report into OpenTelemetry resource attributes and plain metric records. It has no dependency on any @opentelemetry/* package, so you feed the output to the SDK or exporter you already run.


import { createHealthManager, runtimeInfoCheck } from "@nexload-sdk/healthcheck";
import { toOtelMetricRecords, toOtelResourceAttributes } from "@nexload-sdk/healthcheck-otel";
const health = createHealthManager({
service: { name: "api", version: "1.0.0" },
checks: [runtimeInfoCheck()],
});
const report = await health.run("diagnostics");
const resourceAttributes = toOtelResourceAttributes(report);
const records = toOtelMetricRecords(report);

  • toOtelResourceAttributes(report): service.name, service.version, deployment.environment.name, service.instance.id, process.runtime.name, process.runtime.version, host.arch and os.type. A missing value becomes "unknown".
  • toOtelMetricRecords(report): health.status, health.run.duration_ms, health.check.status, health.check.duration_ms, plus every collector metric in report.metrics.
  • Numeric status encoding: ok is 1, degraded is 0.5, unhealthy is 0.
  • No SDK dependency: the functions return plain objects. The package does not create spans, meters or OTLP requests.

Terminal window
pnpm add @nexload-sdk/healthcheck-otel @nexload-sdk/healthcheck

Requires Node.js >=20.9.0 or Bun >=1.0.0.


Optimization

Agent usage

Playground