Skip to content

Production Guides & Recipes

Pass your Bun.serve() server instance into bunServerMetricsCheck:

import { bunServerMetricsCheck } from "@nexload-sdk/healthcheck-bun";
const server = Bun.serve({
fetch(req) { /* ... */ },
websocket: { /* ... */ },
});
const serverCheck = bunServerMetricsCheck(server, {
scopes: ["diagnostics"],
});

The check always reports ok. It records pendingRequests and pendingWebSockets from the server as metrics, so you can alert on them in your monitoring system. It has no thresholds of its own.


1. bunServerMetricsCheck Requires a Valid Server Instance

Section titled “1. bunServerMetricsCheck Requires a Valid Server Instance”

Ensure you pass the return value of Bun.serve() into bunServerMetricsCheck. If called before the server starts, wrap the manager creation in a factory function or attach the check after server initialization.

report.runtime.name will report "bun". If your telemetry tools look for "node", configure your metric exporter to recognize Bun runtime identifiers.