Production Guides & Recipes
Monitoring Bun.serve() Servers
Section titled “Monitoring Bun.serve() Servers”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.
Troubleshooting & Common Pitfalls
Section titled “Troubleshooting & Common Pitfalls”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.
2. Runtime Name Output
Section titled “2. Runtime Name Output”report.runtime.name will report "bun". If your telemetry tools look for "node", configure your metric exporter to recognize Bun runtime identifiers.