Overview
@kubiks/otel-inbound provides comprehensive OpenTelemetry instrumentation for inbound HTTP requests. Automatically trace all incoming requests to your application with detailed metadata about request/response cycles, headers, status codes, and performance metrics.

Visualize every inbound HTTP request with detailed span information including URL, method, headers, response status, and timing.
Installation
Peer Dependencies:
@opentelemetry/api >= 1.9.0Supported Frameworks
Works with any TypeScript framework and Node.js runtime:Next.js
App Router & Pages Router
Fastify
High-performance server
NestJS
Enterprise framework
Express
Classic Node.js server
Remix
Full-stack framework
SvelteKit
Modern web framework
Supported Platforms
Works with any observability platform that supports OpenTelemetry:Quick Start
UseInboundInstrumentation to automatically trace all incoming HTTP requests:
This is zero-config—just add the instrumentation and all inbound requests are automatically traced with no code changes required!
Configuration Options
By default, headers and query strings are captured but not request/response bodies. Enable
captureBody carefully as it can expose sensitive data.What You Get
Each inbound HTTP request automatically creates a span with rich telemetry data:Span Information
Span Information
- Span name: HTTP method + route (e.g.,
GET /api/users) - HTTP method: GET, POST, PUT, DELETE, etc.
- URL: Full request URL including query parameters
- Route: Matched route pattern
- Status code: Response status code (200, 404, 500, etc.)
- Duration: Total request/response time
Request Details
Request Details
- Request headers (configurable)
- Query parameters
- Request body (optional)
- User agent
- Client IP address
- Content type and length
Response Details
Response Details
- Response status code
- Response headers (configurable)
- Response body (optional)
- Content type and length
Performance Metrics
Performance Metrics
- Total request duration
- Time to first byte
- Response size
Error Tracking
Error Tracking
- Exceptions are recorded with stack traces
- Proper span status (OK, ERROR)
- Error messages and HTTP status codes
- Failed request details
Span Attributes
The instrumentation adds the following attributes to each span following OpenTelemetry semantic conventions:| Attribute | Description | Example |
|---|---|---|
http.method | HTTP method | GET |
http.url | Full URL | https://api.example.com/users?page=1 |
http.route | Route pattern | /api/users |
http.status_code | Response status | 200 |
http.user_agent | Client user agent | Mozilla/5.0... |
http.client_ip | Client IP | 192.168.1.1 |
http.request_content_length | Request size (bytes) | 1024 |
http.response_content_length | Response size (bytes) | 2048 |
Usage Examples
Basic HTTP Tracing
Next.js App Router
Next.js Pages Router
Custom Configuration
Error Handling
Complete Integration Example
Here’s a complete example with Inbound instrumentation in a Next.js application:instrumentation.ts
app/api/users/[id]/route.ts
Best Practices
Filter Sensitive Data
Filter Sensitive Data
Be careful with capturing headers and bodies:
Ignore Health Checks
Ignore Health Checks
Exclude monitoring endpoints to reduce noise:
Monitor Performance
Monitor Performance
Use traces to identify slow endpoints and optimize them:
- Look for high-duration spans
- Identify N+1 query problems
- Optimize database queries
- Add caching where appropriate
Set Up Alerts
Set Up Alerts
Configure alerts for high error rates or slow responses based on span data.
Performance Considerations
Minimal Overhead
Minimal Overhead
The instrumentation adds minimal overhead (~1ms per request) for tracing operations.
Sampling
Sampling
Use sampling for high-traffic applications:
Ignore Static Assets
Ignore Static Assets
Don’t trace static assets to reduce volume:
Troubleshooting
Spans Not Appearing
Spans Not Appearing
Ensure OpenTelemetry is initialized before the server starts:
Headers Not Captured
Headers Not Captured
Check that
captureHeaders is enabled:Some Paths Not Traced
Some Paths Not Traced
Check if they’re in the ignore list:
Too Many Spans
Too Many Spans
Consider sampling or ignoring more paths:
Resources
OpenTelemetry HTTP Conventions
Learn about HTTP semantic conventions
GitHub Repository
View source code and examples
npm Package
View package on npm
Report Issues
Found a bug? Let us know!