Framework Integrations
Mount Trasys middleware in Express, Fastify, Hono, or NestJS to capture method, route, status code, latency, user, session, and trace context per request.
Framework Integrations
The SDK provides a middleware for each supported framework. Mount it as early as possible in your middleware stack — before authentication, body parsing, or route handlers — so it captures the full request lifecycle.
What gets captured automatically
Every instrumented request produces a span with:
| Attribute | Description |
|---|---|
| Method + route pattern | /users/:id, not /users/123 |
| Status code + latency | Full end-to-end duration |
| User ID + tenant ID | Read from req.user after your auth middleware runs |
| Session ID | Derived from JWT, cookie, or header per your session config |
W3C traceparent | Extracted from inbound requests for distributed tracing |
x-trasys-trace-id | Injected into responses for frontend correlation |
Supported frameworks
Express
Standard Node.js web framework. Mount sdk.middleware() as the first app.use().
Fastify
High-performance framework. Register sdk.fastifyplugin() as the first plugin.
Hono
Edge-first framework. Apply sdk.honoMiddleware() to all routes.
NestJS
Enterprise framework. Works with both Express and Fastify adapters.
Ignored routes
Routes listed in ignoreRoutes are skipped entirely — no span is created and the request passes through immediately.
Default ignored routes: /health, /healthz, /ping, /metrics, /favicon.ico
createSdk({
ignoreRoutes: ['/health', '/internal/ready', '/internal/live', '/_next'],
});Bun compatibility
All framework middleware works normally on Bun. The SDK detects the Bun runtime at startup and adjusts accordingly.
One limitation on Bun: outbound HTTP spans are not captured. Calls made with fetch will not appear as child spans, and no traceparent header is injected into those requests. Inbound request spans, AI spans, database spans, and all other instrumentation work normally.
Next steps
- Distributed Tracing — how
traceparentpropagates once a request leaves this service - Session Tracking — how the session ID shown above is derived
- Sampling — control which of these requests actually get recorded
Installation & Setup
Install the Trasys SDK with npm and create a dedicated initializer file that must be required before any other library so instrumentation patches load first.
Express
Mount the Trasys SDK's Express middleware as the first app.use() call to capture every inbound request as a span before your other application middleware runs.

