Hono
v3 / v4Ultra-fast edge-ready middleware for Hono v3/v4.
Runs as a Hono middleware on the `*` wildcard. Works on Node.js, Cloudflare Workers, Bun, and Deno.
On edge runtimes (Cloudflare Workers, Bun), process metrics are disabled automatically since `process` is unavailable.
Install
bash
npm install auto-api-observeQuick Start
The minimal setup — import, configure, and you're observing.
hono-quick-start.js
import { Hono } from 'hono';
import { honoObservability } from 'auto-api-observe';
const app = new Hono();
app.use('*', honoObservability({
apiKey: process.env.APILENS_KEY,
}));
app.get('/users', c => c.json({ users: [] }));
export default app;Full Example
All available options with custom fields and real-world usage.
hono-full.js
import { Hono } from 'hono';
import { honoObservability, addField } from 'auto-api-observe';
const app = new Hono();
app.use('*', honoObservability({
apiKey: process.env.APILENS_KEY,
slowThreshold: 300,
tags: { runtime: 'cloudflare', service: 'edge-api' },
}));
app.get('/users/:id', async c => {
addField('userId', c.req.param('id'));
return c.json({ user: { id: c.req.param('id') } });
});
export default app;What's Tracked Automatically
- c.req.method, response status, latency
- Route path from c.req.path
- Origin header / IP from x-forwarded-for
- Outbound calls via fetch (when enabled)
Options Reference
| Option | Type | Default |
|---|---|---|
| apiKey | string | — |
| slowThreshold | number | 1000 |
| skipRoutes | string[] | [] |
| tags | Record | {} |
Custom Fields
Attach any business context to the current request via AsyncLocalStorage — scoped per request, works the same on every framework.
const { addField } = require('auto-api-observe');
// In any route handler:
addField('userId', req.user.id);
addField('plan', req.user.plan);
addField('country', req.headers['cf-ipcountry']);
// Sensitive keys are auto-redacted before shipping:
addField('authorization', token); // → "[REDACTED]"
addField('password', pass); // → "[REDACTED]"Ready to observe your Hono app?
Sign up free — get your API key in under 30 seconds. No credit card required.
Get your free API key