Skip to content

Sampling and redaction

Sampling controls record volume. Redaction removes configured sensitive fields.

Sampling values are numbers from 0 to 1.

Terminal window
const runtime = observability({
name: "runtime",
namespace: "api",
sampling: {
success: 0.25,
error: 1,
},
})

In this example, Layeron emits about 25 percent of success records and all error records.

Use lower success sampling for high-volume routes. Use full error sampling when every failure matters.

Redaction replaces matching field names before attributes leave the handler:

Terminal window
const runtime = observability({
name: "runtime",
namespace: "api",
redaction: {
fields: ["authorization", "cookie", "token"],
},
})

Keep these values out of attributes:

  • Access tokens.
  • Passwords.
  • Cookies.
  • Raw authorization headers.
  • Raw provider payloads.
  • Full request bodies.