Skip to main content

Interface: SamplingConfig

Defined in: nestlens.config.ts:550

Records a fraction of traffic instead of all of it.

Absent by default: NestLens records everything, which is what it is for. This is for an application that has outgrown paying for that on every request and would rather see one request in ten completely than all of them not at all.

Sampling is decided per request, from its id, so a request and everything recorded under it — its queries, cache reads, logs and outgoing calls — are kept together or dropped together. A detail page is therefore always whole.

Cheaper than NestLensConfig.filter for this purpose: the decision is a hash rather than a callback, and it is made before the entry is masked or buffered. Use filter when the rule depends on what is in the entry.

Properties​

always?​

optional always: ("query" | "request" | "exception" | "log" | "cache" | "event" | "job" | "schedule" | "mail" | "http-client" | "redis" | "model" | "notification" | "view" | "command" | "gate" | "batch" | "dump" | "graphql")[]

Defined in: nestlens.config.ts:567

Entry types recorded whatever the rate says. Default: ['exception'].

An exception is the thing you went looking for, and sampling it away is the one outcome that makes the tool useless at the moment it matters. Set it explicitly to change what is exempt — [] exempts nothing.


rate?​

optional rate: number

Defined in: nestlens.config.ts:557

Fraction of requests to record, from 0 to 1. Default: 1, meaning all.

0.1 records a tenth of requests, whole. 0 records nothing except what always names, which is a coherent setting: exceptions only.