autotel 2.21.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +31 -31
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -6,10 +6,10 @@
6
6
 
7
7
  **Write once, observe everywhere.** Instrument your Node.js code a single time, keep the DX you love, and stream traces, metrics, logs, and product events to **any** observability stack without vendor lock-in.
8
8
 
9
- - **Drop-in DX** one `init()` and ergonomic helpers like `trace()`, `span()`, `withTracing()`, decorators, and batch instrumentation.
10
- - **Platform freedom** OTLP-first design plus subscribers for PostHog, Mixpanel, Amplitude, and anything else via custom exporters/readers.
11
- - **Production hardening** adaptive sampling (10% baseline, 100% errors/slow paths), rate limiting, circuit breakers, payload validation, and automatic sensitive-field redaction.
12
- - **Auto enrichment** service metadata, deployment info, and AsyncLocalStorage-powered correlation IDs automatically flow into spans, metrics, logs, and events.
9
+ - **Drop-in DX** : one `init()` and ergonomic helpers like `trace()`, `span()`, `withTracing()`, decorators, and batch instrumentation.
10
+ - **Platform freedom** : OTLP-first design plus subscribers for PostHog, Mixpanel, Amplitude, and anything else via custom exporters/readers.
11
+ - **Production hardening** : adaptive sampling (10% baseline, 100% errors/slow paths), rate limiting, circuit breakers, payload validation, and automatic sensitive-field redaction.
12
+ - **Auto enrichment** : service metadata, deployment info, and AsyncLocalStorage-powered correlation IDs automatically flow into spans, metrics, logs, and events.
13
13
 
14
14
  > Raw OpenTelemetry is verbose, and vendor SDKs create lock-in. Autotel gives you the best parts of both: clean ergonomics **and** total ownership of your telemetry.
15
15
 
@@ -358,8 +358,8 @@ function timed<T>(operation: string, fn: () => Promise<T>): Promise<T> {
358
358
 
359
359
  **Two patterns supported:**
360
360
 
361
- 1. **Factory pattern** `trace(ctx => (...args) => result)` Returns a wrapped function for reuse
362
- 2. **Immediate execution** `trace(ctx => result)` Executes once immediately, returns the result directly
361
+ 1. **Factory pattern** `trace(ctx => (...args) => result)` : Returns a wrapped function for reuse
362
+ 2. **Immediate execution** `trace(ctx => result)` : Executes once immediately, returns the result directly
363
363
 
364
364
  - Automatic span lifecycle (`start`, `end`, status, and error recording).
365
365
  - Function names feed `operation.name`, `code.function`, and events enrichment.
@@ -530,8 +530,8 @@ app.use((req, res, next) => {
530
530
 
531
531
  ### Reusable Middleware Helpers
532
532
 
533
- - `withTracing(options)` create a preconfigured wrapper (service name, default attributes, skip rules).
534
- - `instrument(object, options)` batch-wrap entire modules while skipping helpers or private functions.
533
+ - `withTracing(options)` : create a preconfigured wrapper (service name, default attributes, skip rules).
534
+ - `instrument(object, options)` : batch-wrap entire modules while skipping helpers or private functions.
535
535
 
536
536
  ```typescript
537
537
  import { withTracing, instrument } from 'autotel';
@@ -1576,12 +1576,12 @@ init({
1576
1576
 
1577
1577
  ## Auto Instrumentation & Advanced Configuration
1578
1578
 
1579
- - `autoInstrumentations` Enable OpenTelemetry auto-instrumentations (HTTP, Express, Fastify, Prisma, Pino…). Requires `@opentelemetry/auto-instrumentations-node`.
1580
- - `instrumentations` Provide manual instrumentation instances, e.g., `new HttpInstrumentation()`.
1581
- - `resource` / `resourceAttributes` Declare cluster/region/tenant metadata once and it flows everywhere.
1582
- - `spanProcessor`, `metricReader`, `logRecordProcessors` Plug in any OpenTelemetry exporter or your in-house pipeline.
1583
- - `headers` Attach vendor auth headers when using the built-in OTLP HTTP exporters.
1584
- - `sdkFactory` Receive the Autotel defaults and return a fully customized `NodeSDK` for the rare cases you need complete control.
1579
+ - `autoInstrumentations` : Enable OpenTelemetry auto-instrumentations (HTTP, Express, Fastify, Prisma, Pino…). Requires `@opentelemetry/auto-instrumentations-node`.
1580
+ - `instrumentations` : Provide manual instrumentation instances, e.g., `new HttpInstrumentation()`.
1581
+ - `resource` / `resourceAttributes` : Declare cluster/region/tenant metadata once and it flows everywhere.
1582
+ - `spanProcessor`, `metricReader`, `logRecordProcessors` : Plug in any OpenTelemetry exporter or your in-house pipeline.
1583
+ - `headers` : Attach vendor auth headers when using the built-in OTLP HTTP exporters.
1584
+ - `sdkFactory` : Receive the Autotel defaults and return a fully customized `NodeSDK` for the rare cases you need complete control.
1585
1585
 
1586
1586
  ```typescript
1587
1587
  import { init } from 'autotel';
@@ -1721,12 +1721,12 @@ NODE_OPTIONS="--experimental-loader=@opentelemetry/instrumentation/hook.mjs --im
1721
1721
 
1722
1722
  ## Operational Safety & Runtime Controls
1723
1723
 
1724
- - **Adaptive sampling** 10% baseline, 100% for errors/slow spans by default (override via `sampler`).
1725
- - **Rate limiting & circuit breakers** Prevent telemetry storms when backends misbehave.
1726
- - **Validation** Configurable attribute/event name lengths, maximum counts, and nesting depth.
1727
- - **Sensitive data redaction** Passwords, tokens, API keys, and any custom regex you provide are automatically masked before export.
1728
- - **Auto-flush** Events buffers drain when root spans end (disable with `flushOnRootSpanEnd: false`).
1729
- - **Runtime flags** Toggle metrics or swap endpoints via env vars without code edits.
1724
+ - **Adaptive sampling** : 10% baseline, 100% for errors/slow spans by default (override via `sampler`).
1725
+ - **Rate limiting & circuit breakers** : Prevent telemetry storms when backends misbehave.
1726
+ - **Validation** : Configurable attribute/event name lengths, maximum counts, and nesting depth.
1727
+ - **Sensitive data redaction** : Passwords, tokens, API keys, and any custom regex you provide are automatically masked before export.
1728
+ - **Auto-flush** : Events buffers drain when root spans end (disable with `flushOnRootSpanEnd: false`).
1729
+ - **Runtime flags** : Toggle metrics or swap endpoints via env vars without code edits.
1730
1730
 
1731
1731
  ```bash
1732
1732
  # Disable metrics without touching code (metrics are ON by default)
@@ -2231,17 +2231,17 @@ The `autotel-edge` package is optimized for edge runtimes with automatic flush b
2231
2231
 
2232
2232
  ## API Reference
2233
2233
 
2234
- - `init(config)` Bootstraps the SDK (call once).
2235
- - `trace(fn | name, fn)` Wraps functions with spans and optional context access.
2236
- - `span(options, fn)` Creates nested spans for ad-hoc blocks.
2237
- - `withTracing(options)` Produces reusable wrappers with shared configuration.
2238
- - `instrument(target, options)` Batch-wraps an object of functions.
2239
- - `Trace` decorator Adds tracing to class methods (TypeScript 5+).
2240
- - `instrumentDatabase(db, options)` Adds automatic DB spans (Drizzle, etc.).
2241
- - `Metric` class & helpers (`createHistogram`, etc.) Emit OpenTelemetry metrics.
2242
- - `Event` class & `track()` helper Send product events/funnels/outcomes/values via subscribers.
2243
- - `Logger` interface Bring your own Pino/Winston logger; autotel auto-instruments it for trace context and OTLP export.
2244
- - `PostHogSubscriber`, `MixpanelSubscriber`, … Provided in `autotel-subscribers`; create your own by implementing the `EventSubscriber` interface.
2234
+ - `init(config)` : Bootstraps the SDK (call once).
2235
+ - `trace(fn | name, fn)` : Wraps functions with spans and optional context access.
2236
+ - `span(options, fn)` : Creates nested spans for ad-hoc blocks.
2237
+ - `withTracing(options)` : Produces reusable wrappers with shared configuration.
2238
+ - `instrument(target, options)` : Batch-wraps an object of functions.
2239
+ - `Trace` decorator : Adds tracing to class methods (TypeScript 5+).
2240
+ - `instrumentDatabase(db, options)` : Adds automatic DB spans (Drizzle, etc.).
2241
+ - `Metric` class & helpers (`createHistogram`, etc.) : Emit OpenTelemetry metrics.
2242
+ - `Event` class & `track()` helper : Send product events/funnels/outcomes/values via subscribers.
2243
+ - `Logger` interface : Bring your own Pino/Winston logger; autotel auto-instruments it for trace context and OTLP export.
2244
+ - `PostHogSubscriber`, `MixpanelSubscriber`, … : Provided in `autotel-subscribers`; create your own by implementing the `EventSubscriber` interface.
2245
2245
 
2246
2246
  Each API is type-safe, works in both ESM and CJS, and is designed to minimize boilerplate while staying close to OpenTelemetry primitives.
2247
2247
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel",
3
- "version": "2.21.0",
3
+ "version": "2.22.0",
4
4
  "description": "Write Once, Observe Anywhere",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -238,11 +238,11 @@
238
238
  "@opentelemetry/sdk-metrics": "^2.5.1",
239
239
  "@opentelemetry/sdk-node": "^0.212.0",
240
240
  "@opentelemetry/sdk-trace-base": "^2.5.1",
241
- "@opentelemetry/semantic-conventions": "^1.39.0",
241
+ "@opentelemetry/semantic-conventions": "^1.40.0",
242
242
  "import-in-the-middle": "^3.0.0"
243
243
  },
244
244
  "peerDependencies": {
245
- "@opentelemetry/auto-instrumentations-node": "^0.70.0",
245
+ "@opentelemetry/auto-instrumentations-node": "^0.70.1",
246
246
  "@opentelemetry/exporter-logs-otlp-grpc": "^0.212.0",
247
247
  "@opentelemetry/exporter-logs-otlp-http": "^0.212.0",
248
248
  "@opentelemetry/exporter-metrics-otlp-grpc": "^0.212.0",
@@ -304,7 +304,7 @@
304
304
  "devDependencies": {
305
305
  "@arethetypeswrong/cli": "^0.18.2",
306
306
  "@edge-runtime/vm": "^5.0.0",
307
- "@opentelemetry/auto-instrumentations-node": "^0.70.0",
307
+ "@opentelemetry/auto-instrumentations-node": "^0.70.1",
308
308
  "@opentelemetry/context-async-hooks": "^2.5.1",
309
309
  "@opentelemetry/exporter-logs-otlp-grpc": "^0.212.0",
310
310
  "@opentelemetry/exporter-logs-otlp-http": "^0.212.0",
@@ -318,7 +318,7 @@
318
318
  "@total-typescript/ts-reset": "^0.6.1",
319
319
  "@total-typescript/tsconfig": "^1.0.4",
320
320
  "@types/eslint-config-prettier": "^6.11.3",
321
- "@types/node": "^25.3.0",
321
+ "@types/node": "^25.3.3",
322
322
  "@typescript-eslint/eslint-plugin": "^8.56.1",
323
323
  "@typescript-eslint/parser": "^8.56.1",
324
324
  "eslint-config-prettier": "^10.1.8",