Build on top

Custom enrichers

defineEnricher derives context from request headers, env, or anything else, and adds it to every wide event before drain — without touching call sites.

An enricher runs on every emitted event before it reaches drains. It's the right tool when you want a field on every event without touching every call site — geo, user agent, trace context, deploy id, tenant id…

Canonical guide

Full reference at Custom enrichers:

  • defineEnricher() API
  • Reading request headers
  • Async enrichers
  • Combining built-in + custom

This page exists in the build-on-top section as a pointer — same content, classified by axis.

When to reach for plugins instead

If your feature mixes enrichment with other hooks (e.g. enrich + tail-sample + side-effect on drain), use a plugin instead — one cohesive object covering several lifecycle points.