Guides
Sampling
Every SDK option that drops errors, samples traces or turns data off, with its default.
By default the SDK sends every trace and every error. The options on this page reduce what leaves your app.
import { init } from "@openperf/sdk/browser";
init({
dsn: import.meta.env.VITE_OPENPERF_DSN,
tracesSampleRate: 0.2,
ignoreErrors: ["ResizeObserver loop", /^AbortError: /],
denyUrls: ["https://widgets.example.net/"],
});All options
Prop
Type
Sample traces
tracesSampleRate: 0.2 sends about one trace in five. The decision is made once, when the trace starts, and every span of the trace follows it. With a DSN set, a value outside 0 to 1 makes init throw a RangeError.
- Uncaught errors and errors reported with
captureExceptionare always sent, also from traces that were not sampled. An error that is only recorded on a span, such as one thrown inside astartSpancallback, is dropped with the unsampled span. Logs are not sampled either. - In the browser, web vitals travel with the page load trace. A lower rate means fewer web vitals samples.
- A server follows the decision of the caller when a request carries a
traceparentheader. Its own rate applies to traces that start on the server. See Distributed tracing.
Sample replays
Replays are off by default. replaysSessionSampleRate and replaysOnErrorSampleRate pick the sessions to record, independently of tracesSampleRate. See Session replay.
Drop errors in the browser
The three options run in this order: ignoreErrors, denyUrls, beforeSend. They apply to uncaught errors, to captureException and to errors that fail a span.
ignoreErrorschecks the message. A string matches a message that contains it, aRegExpa message it matches. Both are also tried againstType: message, so/^TypeError: /drops by type.denyUrlschecks the file of the top stack frame only. An error that starts in your code is kept, even when a deeper frame is in a listed file.beforeSendgets the error and returns what to send.
import { init } from "@openperf/sdk/browser";
init({
dsn: import.meta.env.VITE_OPENPERF_DSN,
beforeSend: (captured) => {
if (captured.type === "AbortError") {
return null;
}
return { ...captured, message: captured.message?.replace(/\d{6,}/g, "[number]") };
},
});captured holds error (the thrown value), message, type and stack. Return null to drop the error, or the object with a changed message, type or stack. When the callback throws, the error is sent unchanged. The callback runs once per error object.
These three options exist in the browser only. The server SDK has no options that filter errors.
Send less from the server
init({ dsn: process.env.OPENPERF_DSN, captureLogs: false })keeps traces and errors and stops sending logs.- The SDK stays off when neither
dsnnor theOPENPERF_DSNvariable is set, or whenOTEL_SDK_DISABLED=true, for example in local runs or tests.
What the SDK drops on its own
- In the browser, the same error is sent once a minute at most, and no more than 100 different errors are sent per minute.
- In the browser, script errors from other origins that arrive without an error object are skipped.
- When the server answers
429, the browser SDK pauses for the time inRetry-After: 60 seconds when the header is missing, five minutes at most. Data collected during the pause is dropped. - On the server, the
fs,dns,netandrouterinstrumentations, host metrics and runtime metrics are off.
Filters in the project
A project has its own Inbound filters: Browser extensions, Known browser noise and Web crawlers. They run on the server after the data arrives. See Projects.