inspector.restDocs

Configuration

Every option of create_inspector in the Node.js SDK with its default: ingest key, labels, body capture, sampling, host and path rules, redaction, batching, timeouts and load budget.

create_inspector(config) takes the options below. Everything except server_key is optional. The PHP SDK uses the same names; see PHP SDK.

OptionDefaultDescription
server_key–Ingest key (irk_<org-slug>_<secret>).
server_urlderived from the keyAPI origin override, for local development.
service–Service name stored with every batch. Filter by it in the app and with MCP.
labels{}Labels added to every request. See Labels.
capture_body'always''always', 'on_error' (bodies are kept only for failed requests) or 'never'.
max_body_bytesunlimitedCut text bodies at this many UTF-8 bytes (on a character boundary). The record notes the original size and truncated: true.
capture_binaryfalseUpload binary bodies. When off, only metadata (size and content type) is sent. See Binary bodies.
max_binary_bytes10485760Binary bodies above this size (10 MiB) are not uploaded; only metadata is sent.
sample_rate1Fraction of requests that are recorded (0 to 1). A request is recorded completely or not at all.
include_hosts / exclude_hosts–Host patterns (* wildcard, case-insensitive, port ignored). With include_hosts, only matching hosts are recorded.
include_paths / exclude_paths–Path patterns (* wildcard) matched against the path without the query string.
redact_headers–Header names whose values are replaced with [redacted].
redact_fields–Field names that are redacted in JSON and form bodies and in URL query strings.
redact_hook–(record) => void | false, called with the wire record before it is serialized. Mutate it, or return false to drop the record.
error_details–(error) => object. Adds the error’s own fields as details. A throwing hook is ignored.
batch_bytes1048576A batch is sent when it reaches this size (1 MiB) …
flush_interval_ms1000… or this age.
max_queue_bytes67108864Upper bound of everything the SDK holds in memory (64 MiB). The oldest records are dropped beyond it.
max_in_flight4Batches sent concurrently.
timeout_ms10000Timeout of one send.
close_timeout_ms5000close() and flush() stop waiting after this long.
in_progress_after_ms2000A request that is still running after this long is reported as in progress.
compression'auto''auto' (zstd, else gzip), 'zstd', 'gzip' or 'none'.
failure_threshold / circuit_open_ms3 / 30000After this many failed sends in a row the SDK stops trying for circuit_open_ms. Requests are unaffected; records keep queueing within the bound.
max_cpu_share0.1Load budget: the share of the application thread the SDK may use.
max_bytes_per_second20971520Load budget: compressed bytes sent per second (20 MiB).
auto_flushtrueFlush on beforeExit and on SIGTERM / SIGINT.
worker_threadtrueSerialize, compress and send on a worker thread. See Workers and other runtimes.
fetchglobal fetchCustom fetch used for sending. Forces the main thread.

Methods

Method
flush()Sends everything queued so far and waits (at most close_timeout_ms). Never rejects. Use it with ctx.waitUntil(inspector.flush()) on Workers.
close()Final delivery attempt, including batches in flight and requests still running, then stops the inspector. Bounded by close_timeout_ms.
stats()Counters for diagnostics: state, captured / sent / dropped records, held bytes, shed level and max_block_ms.

Environment variable

The examples in this documentation read the key from INSPECTOR_REST_KEY. The name is a convention; the SDK only sees the value you pass as server_key.