Sampling events
If you’d like to report fewer events in order to minimize your quota
consumption, set events.sampleRatePercentage when configuring Honeybadger:
Honeybadger.configure({ events: { sampleRatePercentage: 10, },});This sends approximately 10% of events. When an event carries a request_id
(for example, from
automatic HTTP instrumentation),
sampling is deterministic per request: all events from the same request are
kept or dropped together. Events without a request_id are sampled randomly.
Per-event sampling override
Section titled “Per-event sampling override”You can override the configured sample rate for a single event by setting
_hb.sampleRate (a number from 0 to 100) on the event data or in a
beforeEvent handler. The _hb key is stripped before the event is sent.
Honeybadger.event("debug.trace", { detail: "noisy", _hb: { sampleRate: 1 },});Or via a handler:
Honeybadger.beforeEvent((event) => { if (event.event_type === "request.handled" && event.status < 400) { event._hb = { sampleRate: 5 }; }});To ignore specific events instead of sampling across the board, see Filtering events.