# healthcheck-otel — Agent usage Configure a coding agent for @nexload-sdk/healthcheck-otel. **Topic:** agents **Package:** `@nexload-sdk/healthcheck-otel` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/otel/agents/ ## Install matching skills Install the skills whose triggers match the task. ### healthcheck-monitoring-exporters [Trigger](https://github.com/gecut/nexload-sdk/blob/main/skills/healthcheck/monitoring-exporters/SKILL.md) ```text Use when converting an existing HealthReport with @nexload-sdk/healthcheck-prometheus or @nexload-sdk/healthcheck-otel, including Prometheus/OpenMetrics text, OTel resource attributes and metric records, collector-only export boundaries, prefixes, metric names, HELP descriptions, label allowlists, dropped labels, deterministic output, and cardinality review. ``` ```bash npx skills add gecut/nexload-sdk --skill healthcheck-monitoring-exporters ``` ### healthcheck-diagnostics-security [Trigger](https://github.com/gecut/nexload-sdk/blob/main/skills/healthcheck/diagnostics-security/SKILL.md) ```text Use when deciding or reviewing public versus private health exposure, diagnostics details, metrics access, JSON redaction, error and stack suppression, bearer or Basic authentication, IPv4/CIDR allowlists, trusted proxy headers, no-store policy, or sensitive and high-cardinality health data. Compose with the route or exporter skill that owns implementation. ``` ```bash npx skills add gecut/nexload-sdk --skill healthcheck-diagnostics-security ``` ## Project AGENTS.md ```markdown For @nexload-sdk/healthcheck-otel, load healthcheck-monitoring-exporters when its trigger matches. Read the package bundle and check public exports against the installed version before editing. ``` ## Package context [Scoped Markdown bundle](/nexload-sdk/packages/healthcheck/otel/llms.txt). ## Prompts ```text Convert a report into OpenTelemetry records. Use @nexload-sdk/healthcheck-otel and healthcheck-monitoring-exporters. Inspect the installed version and show a minimal typed example for my project. ``` ```text Review my @nexload-sdk/healthcheck-otel integration against the optimization page. Identify the relevant source for each finding and one test for the highest-risk behavior. ``` --- # API Reference & Compatibility Public API symbol reference and compatibility matrix for Healthcheck OpenTelemetry. **Topic:** api **Package:** `@nexload-sdk/healthcheck-otel` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/otel/api/ The complete public API symbol inventory is generated automatically from package source exports: ## Functions ### `toOtelMetricRecords` ```ts toOtelMetricRecords(report: HealthReport) => OtelMetricRecord[] ``` **Exported from:** `@nexload-sdk/healthcheck-otel` Public function exported by @nexload-sdk/healthcheck-otel. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/otel/src/index.ts#L36) ### `toOtelResourceAttributes` ```ts toOtelResourceAttributes(report: HealthReport) => Record ``` **Exported from:** `@nexload-sdk/healthcheck-otel` Public function exported by @nexload-sdk/healthcheck-otel. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/otel/src/index.ts#L23) ## Interfaces ### `OtelMetricRecord` ```ts interface OtelMetricRecord { name: string value: HealthMetricValue attributes: Record unit?: string type?: HealthMetric["type"] observedAt: string } ``` **Exported from:** `@nexload-sdk/healthcheck-otel` Public interface exported by @nexload-sdk/healthcheck-otel. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/otel/src/index.ts#L7) *** ## Runtime Compatibility Matrix | Runtime / Engine | Version Requirement | Verification Status | |---|---|---| | **Node.js** | `>=20.9.0` | Verified on Node 20 & 22 | | **Bun** | `>=1.0.0` | Verified on Bun 1.1+ | | **Module Format** | ESM only | Native ECMAScript Modules | | **Side Effects** | `false` | Fully tree-shakeable | --- # Production Guides & Recipes Attaching health metrics to OpenTelemetry spans, semantic conventions, and troubleshooting. **Topic:** guides **Package:** `@nexload-sdk/healthcheck-otel` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/otel/guides/ ## Record Health Metrics with Your OpenTelemetry SDK The package returns data. Your application owns the OpenTelemetry SDK, the meter and the exporter. This example assumes `@opentelemetry/api` is already set up in your service: ```ts import { toOtelMetricRecords } from "@nexload-sdk/healthcheck-otel"; import { metrics } from "@opentelemetry/api"; import { health } from "@/lib/health"; const meter = metrics.getMeter("health"); const gauges = new Map>(); export async function recordHealth() { const report = await health.run("diagnostics"); for (const record of toOtelMetricRecords(report)) { let gauge = gauges.get(record.name); if (!gauge) { gauge = meter.createGauge(record.name, { unit: record.unit }); gauges.set(record.name, gauge); } gauge.record(record.value, record.attributes); } } ``` Each `OtelMetricRecord` has `name`, `value`, `attributes`, `observedAt`, and optional `unit` and `type`. *** ## Resource Attributes Use `toOtelResourceAttributes(report)` when you build the SDK resource or when you want to tag a log record: ```ts import { toOtelResourceAttributes } from "@nexload-sdk/healthcheck-otel"; const attributes = toOtelResourceAttributes(report); // { "service.name": "api", "service.version": "1.0.0", "process.runtime.name": "node", ... } ``` *** ## Emitted Metric Records | Metric name | Unit | Source | |---|---|---| | `health.status` | `state` | Aggregate report status (`1`, `0.5`, `0`) | | `health.run.duration_ms` | `milliseconds` | `report.durationMs` | | `health.check.status` | `state` | Status of each check (`1`, `0.5`, `0`) | | `health.check.duration_ms` | `milliseconds` | Duration of each check | | collector metrics | `metric.unit` | Every entry in `report.metrics` | *** ## Troubleshooting & Common Pitfalls ### 1. Nothing Reaches the Collector The package does not send data. If no metric arrives, check the OpenTelemetry SDK and exporter in your application. ### 2. Collector Metrics Are Missing Collector metrics come from `report.metrics`. Register collectors on the manager, and run a scope and profile that include them. --- # Overview & Quick Start Export healthcheck reports as OpenTelemetry metrics, log attributes, and span metadata. **Topic:** overview **Package:** `@nexload-sdk/healthcheck-otel` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/otel/ **Package:** `@nexload-sdk/healthcheck-otel` **Workspace version:** `3.0.1` OpenTelemetry-friendly transforms for @nexload-sdk/healthcheck reports. [npm](https://www.npmjs.com/package/@nexload-sdk/healthcheck-otel) · [Source](https://github.com/gecut/nexload-sdk/tree/main/packages/healthcheck/otel) `@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. *** ## 10-Second Code Snippet ```ts 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); ``` *** ## What You Get * **`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. *** ## Installation & Requirements ```bash pnpm add @nexload-sdk/healthcheck-otel @nexload-sdk/healthcheck ``` Requires Node.js `>=20.9.0` or Bun `>=1.0.0`. *** ## Next Steps * Explore [Production Guides & OTel Recipes](./guides/) to record the output with your own OpenTelemetry SDK. * Check the [API Reference & Signatures](./api/) for the two functions and the `OtelMetricRecord` shape. ## Next steps [Optimization](./optimization/) [Agent usage](./agents/) [Playground](./playground/) --- # healthcheck-otel — Optimization Production choices for @nexload-sdk/healthcheck-otel. **Topic:** optimization **Package:** `@nexload-sdk/healthcheck-otel` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/otel/optimization/ ## Bound attribute cardinality Keep user IDs, request IDs and raw error text out of collector labels. These labels become metric attributes. ## Publish custom values through collectors Read exported values from report.metrics. Check-local metrics stay in the JSON report. ## Separate mapping from delivery The package maps an existing report to resource attributes and metric records. It runs in Node.js, Bun, Edge, and browsers. ## Avoid sensitive attributes Collector labels become metric attributes. Review their values before exposing records to a monitoring backend. ## Sources [Package guidance](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/otel/README.md) · [Implementation](https://github.com/gecut/nexload-sdk/blob/main/packages/healthcheck/otel/src/index.ts). · [Matching skill](https://github.com/gecut/nexload-sdk/blob/main/skills/healthcheck/monitoring-exporters/SKILL.md). --- # healthcheck-otel — Playground Inspect a local readiness report. **Topic:** playground **Package:** `@nexload-sdk/healthcheck-otel` v3.0.1 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/healthcheck/otel/playground/ ## Try it Type ok, degraded or unhealthy to change a critical inventory check. Switch between the report and three export formats. ## Read the result The local manager runs a readiness check. Prometheus renders metric text, OpenMetrics adds the EOF marker, and OTel returns metric records. No network service receives the output. Enter `unhealthy`. The `health.status` metric record has value `0`. [API reference](/nexload-sdk/packages/healthcheck/otel/api/).