
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
@atrim/instrument-node
Advanced tools
OpenTelemetry instrumentation for Node.js with centralized YAML configuration
Configuration layer for OpenTelemetry Node.js
Built on @opentelemetry/auto-instrumentations-node, this package adds centralized YAML configuration, pattern-based span filtering, and first-class Effect-TS integration.
| Feature | Description |
|---|---|
| Pattern-based span filtering | Control which spans are created via YAML config (unique to this package) |
| Centralized configuration | Load instrumentation config from file, URL, or environment variable |
| Effect-TS integration | Typed layers, annotation helpers for Effect users |
| Smart defaults | Auto-detects service name, configures graceful shutdown |
Note: Auto-instrumentation for Express, HTTP, Fastify, etc. comes from the underlying OpenTelemetry packages. This library configures and extends that functionality.
# Required
npm install @atrim/instrument-node @opentelemetry/api
# Optional: Effect-TS integration
npm install effect @effect/opentelemetry @effect/platform @effect/platform-node
import { initializeInstrumentation } from '@atrim/instrument-node'
await initializeInstrumentation()
// Done! Traces go to http://localhost:4318
Remote collector:
await initializeInstrumentation({
otlp: { endpoint: 'https://otel-collector.company.com:4318' }
})
What gets auto-configured:
package.jsonimport { Effect, Layer } from 'effect'
import { EffectInstrumentationLive } from '@atrim/instrument-node/effect'
const program = Effect.gen(function* () {
yield* myOperation.pipe(Effect.withSpan('app.operation'))
}).pipe(Effect.provide(EffectInstrumentationLive))
await Effect.runPromise(program)
Span annotation helpers:
import { annotateUser, annotateBatch, annotateCache } from '@atrim/instrument-node/effect'
const process = Effect.gen(function* () {
yield* annotateUser('user-123', 'user@example.com')
yield* annotateBatch(100, 10)
yield* annotateCache(true, 'user:123')
// ...
}).pipe(Effect.withSpan('batch.process'))
Available: annotateUser, annotateBatch, annotateDataSize, annotateLLM, annotateQuery, annotateHttpRequest, annotateError, annotatePriority, annotateCache
Automatically trace Effect.all, Effect.forEach, and other operations without manual Effect.withSpan() calls:
import { Effect } from 'effect'
import { withOperationTracing } from '@atrim/instrument-node/effect/auto'
const program = Effect.gen(function* () {
// Automatically creates span "effect.all (index.ts:42)" with item_count=3
yield* Effect.all([fetchUser(), fetchOrders(), fetchPrefs()])
// Automatically creates span "effect.forEach (index.ts:45)"
yield* Effect.forEach(items, processItem)
}).pipe(withOperationTracing)
await Effect.runPromise(program)
What you get:
effect.all (index.ts:42)effect.operation, effect.item_count, code.filepath, code.linenoConfiguration (optional):
effect:
operation_tracing:
enabled: true
operations:
- name: all
include_count: true
- name: forEach
include_count: true
Note: Requires
@clayroach/effectfork with OperationMeta support. See examples/effect-op-tracing for a complete example.
To add Effect fiber metadata (fiber ID, status, parent span info) to your spans, you must explicitly call the enrichment functions:
import { autoEnrichSpan, withAutoEnrichedSpan } from '@atrim/instrument-node/effect'
// Option 1: Call autoEnrichSpan() inside a span
const operation = Effect.gen(function* () {
yield* autoEnrichSpan() // Adds fiber metadata to current span
// ... your logic
}).pipe(Effect.withSpan('app.operation'))
// Option 2: Use the convenience wrapper
const operation = withAutoEnrichedSpan('app.operation')(
Effect.gen(function* () {
// ... your logic (fiber metadata added automatically)
})
)
Extracted metadata:
effect.fiber.id - Unique fiber thread nameeffect.fiber.status - Current fiber statuseffect.operation.root / effect.operation.nested - Operation hierarchyeffect.parent.span.id, effect.parent.span.name, effect.parent.trace.id - Parent span infoNote: The
auto_extract_metadataconfig option is currently not implemented. Metadata extraction requires explicit calls as shown above. See [#issue] for tracking automatic extraction support.
Create instrumentation.yaml in your project root:
version: "1.0"
instrumentation:
enabled: true
instrument_patterns:
- pattern: "^app\\." # Trace app operations
ignore_patterns:
- pattern: "^health\\." # Skip health checks
http_filtering:
enabled: true
ignore_routes:
- pattern: "^/health$"
- pattern: "^/metrics$"
Priority order: Explicit config > ATRIM_INSTRUMENTATION_CONFIG env var > ./instrumentation.yaml > defaults
| Runtime | Version |
|---|---|
| Node.js | 20+ |
| Bun | 1.0+ |
| Deno | 1.40+ |
| Framework | Support |
|---|---|
| Express | Auto-instrumented (via OTel) |
| Fastify | Auto-instrumented (via OTel) |
| Koa | Auto-instrumented (via OTel) |
| Hono | Manual spans |
| Effect-TS | First-class integration (unique) |
| @atrim/instrument-node | @opentelemetry/api | effect |
|---|---|---|
| 0.6.x | ^1.0.0 (1.0 - 1.9+) | ^3.0.0 (optional) |
Notes:
@opentelemetry/api is the only required peer dependencyNo traces? Check collector: docker run -p 4318:4318 otel/opentelemetry-collector
Too many traces? Add HTTP filtering patterns for health checks, metrics, OTLP exports.
Effect spans missing? Ensure you're using Effect.withSpan() and providing EffectInstrumentationLive.
MIT
FAQs
OpenTelemetry instrumentation for Node.js with centralized YAML configuration
The npm package @atrim/instrument-node receives a total of 199 weekly downloads. As such, @atrim/instrument-node popularity was classified as not popular.
We found that @atrim/instrument-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.