esbuild-otel-instrumentation

Installation
SKILL.md

esbuild ESM bundle で OTel auto-instrumentation が動かない

症状

Hono / Node TypeScript アプリで:

  • @opentelemetry/sdk-node または @opentelemetry/sdk-trace-node を register
  • @opentelemetry/instrumentation-http / instrumentation-grpc 等を registerInstrumentations() で追加
  • アプリ起動 / リクエスト処理は正常
  • collector に span が一切届かない (no error, no log)

原因

@opentelemetry/instrumentation-* 系は内部で require-in-the-middle を使って CommonJS の require() を hook して target module (node:http 等) に monkey-patch を仕込む。

esbuild で --format=esm bundle すると、bundle 内の import { createServer } from "node:http"ESM static import に変換され、require() は呼ばれない → hook が発火しない → patch されない → span が作られない。

エラーは出ない (silent failure)。

Related skills

More from mizchi/skills

Installs
4
Repository
mizchi/skills
GitHub Stars
186
First Seen
1 day ago