How to get deep traces in your Node.js backend with OTel and Deno
Running an unmodified Node.js Express server under Deno 2.2+ with the `--unstable-otel` flag yields OpenTelemetry traces and span-correlated logs with no code changes. Deno auto-instruments `console.log`, `fetch` and `Deno.serve()`. The comparison is a small ChatGPT-backed chat app viewed in Grafana's otel-lgtm Docker stack (Tempo for traces). The plain-Node route needed eight @opentelemetry dependencies, an 84-line telemetry.js configuring NodeSDK exporters and HTTP instrumentation, and a custom logger that attaches trace IDs. In Deno, a few environment variables are enough, though the feature is still experimental.
Related posts
- Zero-config Debugging with Deno and OpenTelemetry
Deno mediumAdeptDeno's built-in OpenTelemetry support (enabled with --unstable-otel) automatically correlates console.log output with trace IDs, creates spans for incoming and outgoing HTTP requests, propagates W3C tracecontext headers across services, and records request-count and latency metrics by status code, all without code changes. The walkthrough shows why interleaved logs need request correlation and how spans and parent span IDs build a trace. It provides a withSpan helper around startActiveSpan for adding custom spans such as database calls, and contrasts automatic propagation with manually injecting traceparent headers.
- Build a dinosaur runner game with Deno, pt. 6
Deno mediumAdeptThe final stage of the Deno dinosaur runner series adds observability using Deno Deploy's built-in logs, traces and metrics dashboards. A logging middleware emits one structured JSON line per HTTP request, and route handlers log business events like score submissions and customization saves. Custom OpenTelemetry spans wrap the leaderboard, score submission and customization routes, carrying attributes, events and recorded exceptions. Platform metrics (status codes, latency, CPU, memory, GC time, bandwidth) are used to spot anomalies before drilling into traces, and the `--tunnel` flag sends local telemetry to the same dashboards for verification before deploying.
- Deno 2.2: OpenTelemetry, Lint Plugins, node:sqlite
Deno mediumAdeptDeno 2.2 adds built-in OpenTelemetry that auto-instruments console.log, Deno.serve and fetch and exports to an OTLP endpoint behind the --unstable-otel flag. It also adds an ESLint-like JavaScript lint plugin API with visitor and CSS-selector syntax, 15 new JSX/React lint rules, and support for node:sqlite. Other changes include JSDoc @import support and per-workspace compilerOptions in deno check, 5-20x faster LSP completions, wildcard and command-less tasks, interactive deno outdated, smaller and faster deno compile output, explicit warmup and n options for deno bench, WebTransport/QUIC APIs, and upgrades to TypeScript 5.7 and V8 13.4.
- Sentry JavaScript SDK v11 adds tracing for all JS platforms
Sentry mediumAdeptSentry's JavaScript SDK v11 replaces OpenTelemetry export-patching instrumentations (require-in-the-middle, import-in-the-middle, shimmer) with a source-code transformer that injects node:diagnostics_channel tracingChannel calls into library functions, plus integrations that subscribe to those channels and emit Sentry spans. Because the transform rewrites source rather than mutating exports, it runs both at runtime via Module.registerHooks and at build time via Vite, Rollup, webpack, esbuild and bun build plugins. That makes bundled deployments, Cloudflare Workers, Deno and Bun traceable and removes preload hacks and most OpenTelemetry dependencies. Caveats: load order still matters, --require is dropped, instrumented libraries must not be externalized, Bun runtime hooks are blocked by a CJS export bug, and debug: true reports what got injected.
- OpenTelemetry for JavaScript Observability at Zalando
Zalando Engineering mediumAdeptZalando built thin OpenTelemetry-based observability SDKs for Node.js and the browser, sharing a common API package so isomorphic apps can be instrumented consistently. The Node.js SDK autoconfigures from Kubernetes environment variables and ships default runtime metrics (CPU, memory, GC, event loop lag) plus opt-in HTTP/Express instrumentation. The browser SDK was trimmed to about 30 KB by cherry-picking packages and lazy-loading the rest. It exports telemetry via sendBeacon through the Skipper edge proxy, gated on GDPR consent, and is exposed to frontend developers through Rendering Engine renderer APIs. Key lessons include avoiding OpenTelemetry context (Zone.js in browsers, and migration friction from OpenTracing) in favour of passing spans manually, and defining custom histogram buckets so Core Web Vitals such as LCP and CLS get meaningful percentiles.