Defjs
OpenTelemetry Server

OpenTelemetryServerHttpOptions

Options for the HTTP transport — the shared options with an HttpResponse in responseHook.

@defjs/opentelemetry-server · Type

Signature

type OpenTelemetryServerHttpOptions =
  OpenTelemetryServerTransportOptions<HttpResponse<unknown>>;

Set on http in OpenTelemetryServerOptions. It has no fields of its own: enabled, startSpanHook, requestHook and responseHook come from OpenTelemetryServerTransportOptions.

  • responseHook(span, res, req) receives the HttpResponse that came back through the interceptor, before the client decodes a declared body, together with the original HttpRequest. Read req.operation for the request identity; do not rebuild it from the endpoint or a resolved URL.

  • The HTTP span ends as soon as responseHook returns; the hook is not awaited, so only its synchronous part can still change the span. A status of 400 or above ends it ERROR with error.type set to the status string; 100–399 leaves its status unset. An asynchronous hook rejection after end is reported through diag.error; configure diag.setLogger(...) from @opentelemetry/api to receive it. It cannot append events to an ended span.

  • A rejection through the interceptor has no response status and does not call responseHook. That includes a network failure, caller cancellation, an abort whose reason is TimeoutError, any declared-body read failure (BodyFailure, including text, blob, and bytes, not only JSON), and a progress observer failure (EXT_OBSERVER_FAILED). The span ends ERROR with error.type set to the thrown class name, such as TypeError, Error or BodyFailure. Caller cancellation is Error whatever the abort reason. There is no timeout option; a deadline is signal.

Pass { enabled: false } to skip HTTP instrumentation. Span hooks run only when a tracer is supplied.

Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao