Files
agentic-dev/docs/library-decisions/2026-05-14-@opentelemetry/context-async-hooks.md
Danijel Martinek f77e6ea881 chore(template): clean-slate template snapshot from bb4a0c7
Curated, product-agnostic snapshot of the post-story-04 tree: demo
content deleted, auth-only reference feature, web-next shell, all gates
green. Product-specific docs, ADRs 027-029, PRDs/epics/archive, editor
library traces, and product naming are curated out; generic template
repairs (coverage provider devDeps, root test:coverage script, live
lint fixes, root-only release-please) are kept. See TEMPLATE.md for
provenance, curation list, and usage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
2026-07-12 20:40:54 +02:00

88 lines
3.4 KiB
Markdown

---
package: "@opentelemetry/context-async-hooks"
version: "^1.28.0"
tier: core
decision: approved
date: 2026-05-14
deciders: [Danijel Martinek]
adr: adr-017
filter-results:
license: Apache-2.0
types: native
maintenance: active
boundary-fit: pass
shadow-check: pass
eu-residency: n/a
cve-scan: clean
named-consumer: pass
socketRisk: clean
verification-commands:
- npm view @opentelemetry/context-async-hooks license
- npm view @opentelemetry/context-async-hooks version
- pnpm audit --audit-level=moderate
accepted-cves: []
---
## Filter: license
<!-- Result: Apache-2.0 -->
`npm view @opentelemetry/context-async-hooks license` returns `Apache-2.0`. Apache-2.0 is on the allowlist.
## Filter: types
<!-- Result: native -->
`@opentelemetry/context-async-hooks` is authored in TypeScript and ships its own `.d.ts` declaration files. No separate `@types/` package is needed.
## Filter: maintenance
<!-- Result: active -->
Actively maintained by the OpenTelemetry community. Versioned with the OTel JS SDK at 1.x; the package tracks Node.js async_hooks API stability and receives updates alongside the SDK.
## Filter: boundary-fit
<!-- Result: pass -->
ADR-017 mandates OTel as the instrumentation substrate. `@opentelemetry/context-async-hooks` provides the Node.js `AsyncLocalStorage`-based context manager required for automatic span propagation across async boundaries. It lives exclusively in `core-shared/instrumentation/otel/` and `core-audit` init paths.
## Filter: shadow-check
<!-- Result: pass -->
`@opentelemetry/context-async-hooks` is the standard OTel context manager for Node.js. No competing context propagation mechanism is present in the workspace.
## Filter: eu-residency
<!-- Result: n/a -->
`@opentelemetry/context-async-hooks` is a pure context propagation adapter with no network communication or data transmission. EU residency does not apply.
## Filter: cve-scan
<!-- Result: clean -->
`pnpm audit --audit-level=moderate` reports no advisories against `@opentelemetry/context-async-hooks` at the time of this trace.
## Filter: named-consumer
<!-- Result: pass -->
`packages/core-shared/src/instrumentation/otel/` registers `AsyncLocalStorageContextManager` from this package during OTel SDK init to enable automatic trace context propagation across Node.js async operations. `packages/core-audit` depends on it for span context in audit records.
## Prompt: replaces
Replaces the manual context threading that would otherwise be required to pass span context through async call chains. Without this package, every async function would need to explicitly forward a context argument — defeating the automatic propagation guarantee of OTel.
## Prompt: migration-cost-out
Low. `@opentelemetry/context-async-hooks` is registered in one place during OTel SDK initialization. Swapping to a different context manager (e.g., `@opentelemetry/context-zone` for browser) is a one-line change in the SDK init file.
## Prompt: alternatives-considered
1. **`@opentelemetry/context-zone`** — Zone.js-based context manager designed for Angular/browser environments. Not applicable for a Node.js server; `async_hooks` is the correct primitive for server-side async context.
2. **Manual context passing** — Thread context explicitly through every function signature. Rejected: error-prone at scale and defeats the auto-instrumentation value of the OTel SDK.
See ADR-017 for the full decision rationale.