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 theHttpResponsethat came back through the interceptor, before the client decodes a declared body, together with the originalHttpRequest. Readreq.operationfor the request identity; do not rebuild it from the endpoint or a resolved URL. -
The HTTP span ends as soon as
responseHookreturns; the hook is not awaited, so only its synchronous part can still change the span. A status of 400 or above ends itERRORwitherror.typeset to the status string; 100–399 leaves its status unset. An asynchronous hook rejection after end is reported throughdiag.error; configurediag.setLogger(...)from@opentelemetry/apito 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 isTimeoutError, any declared-body read failure (BodyFailure, including text, blob, and bytes, not only JSON), and a progress observer failure (EXT_OBSERVER_FAILED). The span endsERRORwitherror.typeset to the thrown class name, such asTypeError,ErrororBodyFailure. Caller cancellation isErrorwhatever the abort reason. There is notimeoutoption; a deadline issignal.
Pass { enabled: false } to skip HTTP instrumentation. Span hooks run only when a tracer is supplied.