HBForge/Examples
25 · Integrations

Apitally — or use webLogger and forge/trace

Built-in webLogger() covers basics; forge/trace gives OpenTelemetry-compatible distributed tracing. Both work alongside any 3rd-party APM.

forge/serverforge/traceNodeBunDenoCF Workers
Code
apitally.js
const { WebApp, webLogger } =
  require(class="tk-str">'@hyperbridge/forge/server');
const { tracer } = require(class="tk-str">'@hyperbridge/forge/trace');

const app = new WebApp();

class="tk-cm">// Built-in request logger
app.use(class="tk-str">'*', webLogger());

class="tk-cm">// Custom metrics middleware — send to any APM
app.use(class="tk-str">'*', async (c, next) => {
  const span = tracer.startSpan(class="tk-str">'http.request');
  span.setAttribute(class="tk-str">'http.method', c.req.method);
  span.setAttribute(class="tk-str">'http.path',   c.req.path);

  await next();

  span.setAttribute(class="tk-str">'http.status', c.res?.status ?? 0);
  span.end();
});

app.get(class="tk-str">'/health', (c) => c.json({ ok: true }));
app.listen(3000);
How it works

webLogger() emits one line per request — method, path, status, duration. Configure with { write: fn } to ship to your log aggregator.

forge/trace emits W3C Trace Context-compatible spans, exportable to Jaeger, Tempo, Honeycomb, or any OTLP backend.

For Apitally specifically, drop their npm package in alongside — it reads from the same Fetch Response object WebApp produces.

Try it
Quickstart
npm i @hyperbridge/forge && app.use('*', webLogger())
Related modules