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.
| Option | Default | Description |
|---|---|---|
server_key | – | Ingest key (irk_<org-slug>_<secret>). |
server_url | derived from the key | API 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_bytes | unlimited | Cut text bodies at this many UTF-8 bytes (on a character boundary). The record notes the original size and truncated: true. |
capture_binary | false | Upload binary bodies. When off, only metadata (size and content type) is sent. See Binary bodies. |
max_binary_bytes | 10485760 | Binary bodies above this size (10 MiB) are not uploaded; only metadata is sent. |
sample_rate | 1 | Fraction 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_bytes | 1048576 | A batch is sent when it reaches this size (1 MiB) … |
flush_interval_ms | 1000 | … or this age. |
max_queue_bytes | 67108864 | Upper bound of everything the SDK holds in memory (64 MiB). The oldest records are dropped beyond it. |
max_in_flight | 4 | Batches sent concurrently. |
timeout_ms | 10000 | Timeout of one send. |
close_timeout_ms | 5000 | close() and flush() stop waiting after this long. |
in_progress_after_ms | 2000 | A 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_ms | 3 / 30000 | After 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_share | 0.1 | Load budget: the share of the application thread the SDK may use. |
max_bytes_per_second | 20971520 | Load budget: compressed bytes sent per second (20 MiB). |
auto_flush | true | Flush on beforeExit and on SIGTERM / SIGINT. |
worker_thread | true | Serialize, compress and send on a worker thread. See Workers and other runtimes. |
fetch | global fetch | Custom 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.