Skip to main content
The HTTP Server instrumentation traces every incoming HTTP request by injecting TraceRequestMiddleware into the global middleware stack automatically. No manual setup is required beyond enabling the instrumentation. Each request produces a span named {method} {route} (e.g. GET /users/{id}), using the matched route pattern for low cardinality.

Configuration

In config/opentelemetry.php:
use Keepsuit\LaravelOpenTelemetry\Instrumentation;

'instrumentation' => [
    Instrumentation\HttpServerInstrumentation::class => [
        'enabled' => env('OTEL_INSTRUMENTATION_HTTP_SERVER', true),
        'excluded_paths' => [],
        'excluded_methods' => [],
        'allowed_headers' => [],
        'sensitive_headers' => [],
        'sensitive_query_parameters' => [],
    ],
],

Configuration Options

OptionTypeDescription
excluded_pathsstring[]List of URL paths to exclude from tracing. Leading slashes are stripped automatically.
excluded_methodsstring[]List of HTTP methods to exclude (e.g. HEAD, OPTIONS). Values are uppercased automatically.
allowed_headersstring[]Request/response headers to capture and attach as span attributes.
sensitive_headersstring[]Headers containing sensitive data whose values are redacted in the trace.
sensitive_query_parametersstring[]Query string parameters whose values are redacted in the trace.
Common sensitive headers such as Authorization and Cookie are redacted by default. You can extend this list with the sensitive_headers option.

Span Details

  • Span name: {method} {route} — e.g. GET /api/users/{id}
  • Span kind: SERVER
  • Middleware class: \Keepsuit\LaravelOpenTelemetry\Instrumentation\Support\Http\Server\TraceRequestMiddleware
The middleware is prepended to the global middleware stack so it wraps the entire request lifecycle, including other middleware.

Metrics

MetricTypeUnitDescription
http.server.request.durationHistogramsecondsDuration of incoming HTTP request processing.

Disabling

Set the environment variable to false to disable this instrumentation:
OTEL_INSTRUMENTATION_HTTP_SERVER=false
Alternatively, remove HttpServerInstrumentation::class from the instrumentation array in config/opentelemetry.php.

Build docs developers (and LLMs) love