Skip to main content

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.
Inbound Request Trace Visualization
Visualize every inbound HTTP request with detailed span information including URL, method, headers, response status, and timing.

Installation

Peer Dependencies: @opentelemetry/api >= 1.9.0

Supported 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

Use InboundInstrumentation 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 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 headers (configurable)
  • Query parameters
  • Request body (optional)
  • User agent
  • Client IP address
  • Content type and length
  • Response status code
  • Response headers (configurable)
  • Response body (optional)
  • Content type and length
  • Total request duration
  • Time to first byte
  • Response size
  • 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:

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

Be careful with capturing headers and bodies:
Exclude monitoring endpoints to reduce noise:
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
Configure alerts for high error rates or slow responses based on span data.

Performance Considerations

The instrumentation adds minimal overhead (~1ms per request) for tracing operations.
Use sampling for high-traffic applications:
Don’t trace static assets to reduce volume:

Troubleshooting

Ensure OpenTelemetry is initialized before the server starts:
Check that captureHeaders is enabled:
Check if they’re in the ignore list:
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!

License

MIT