Skip to content

Introduction

Autotel is a zero-boilerplate OpenTelemetry wrapper for TypeScript. It replaces 30+ lines of SDK setup with a single init() call and replaces manual span lifecycle with functional trace() wrappers.

  • Write once, observe everywhere: One instrumentation surface; many backends via OTLP.
  • Functional API: Wrap handlers and functions with trace(), span(), instrument(); avoid manual span lifecycle.
  • Structured errors: Errors carry message, why, fix, link so agents and users can diagnose and act.
  • Request context: Use getRequestLogger() when you need one coherent snapshot per request.
NeedAPI / entry point
Wrap a function with a spantrace(fn), span(name, fn), instrument({ key, fn })
Request-scoped attributesgetRequestLogger(ctx?)
Structured throwcreateStructuredError({ message, why?, fix?, link?, status?, code?, cause? })
Parse API errors (client)parseError(err)
Product/analytics eventstrack(name, attributes)
Init (once at startup)init({ service, ... })
TestingcreateTraceCollector() from autotel/testing
Security observability hookssecurityEvent() from autotel-audit. See Security Observability.
Input validation telemetrydefineValidator() from autotel/validate. See Validation Telemetry.
Audit / compliance trailwithAudit() from autotel-audit. See Audit Logging.
Terminal window
npm install autotel
# or
pnpm add autotel

For auto-instrumentation (HTTP, databases, etc.), also install:

Terminal window
npm install @opentelemetry/auto-instrumentations-node