Skip to content

Observability is infrastructure, not an add-on

Standardize logs, metrics, and traces per domain so production incidents point to the right team.

nestjs-resilience-observability-infrastructure

Why it matters

Failure modes if this rule is ignored
StakeIf ignored
Blind in prod
  • When something breaks, the first question is "which domain?" If the logs don't know — you're blind.
  • Without a standard, you end up with five log formats and can't search anything.

How to fix

Logs, metrics, and traces come out of one shared platform library. Every domain uses it — does not roll its own. Every log carries domain and requestId by default.

Examples

Bad
ts
// in one domain
console.log('site created', siteId);

// in another
logger.info({ event: 'agent_started', agent_id: agentId });

// in a third
console.log(`[STUDIO] running agent ${name} at ${new Date()}`);
Good
ts
// libs/shared/observability/src/lib/logger.ts
export function createLogger(domain: string) {
  return baseLogger.child({ domain });
}

// in a domain
import { createLogger } from '@acme/shared/observability';
const log = createLogger('sites-management');

log.info({ event: 'site.created', siteId });

Contribute

Released under the MIT License.

esc