sillsdev / sillsdev/languageforge-lexbox
lexbox-ui: replace @opentelemetry/auto-instrumentations-node with an explicit instrumentation set
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9
- Forks
- 8
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 49
Description
Context
Follow-up from a Docker image-size audit of lexbox-ui. After prod-pruning node_modules in the image (dropping devDependencies), the runtime node_modules is ~275 MB, of which ~51 MB (~19%) is @opentelemetry/* plus the instrumentation packages it pulls in.
frontend/src/lib/otel/otel.server.ts uses:
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-fs': { enabled: false },
})
@opentelemetry/auto-instrumentations-node is a meta-package that drags in ~30 instrumentation packages (gRPC, AWS, Redis, Mongo, MySQL, Kafka, etc.) — almost all for libraries this app doesn't use. The code comment even notes it "Doesn't seem to do anything in our case (except for fs, which is disabled)."
Proposal
Replace getNodeAutoInstrumentations() with an explicit, minimal instrumentation list — likely just HTTP/undici (@opentelemetry/instrumentation-http, @opentelemetry/instrumentation-undici) — or drop auto-instrumentation entirely if the manual spans already in otel.server.ts (traceRequest / traceFetch) cover what we need. Then depend only on the specific instrumentation packages instead of the meta-package.
Benefits:
- Removes most of the ~51 MB OTel footprint from the runtime image and dependency tree.
- Faster cold start (fewer instrumentation modules loaded and patched at startup).
Caveats
- Behavioral change to tracing — verify the spans we rely on (HTTP server spans, outbound fetch spans,
traceparentpropagation to the backend) still show up in the collector after the change. - Keep the OTel packages as regular
dependencies— they must stay external so import-in-the-middle instrumentation hooks work. Bundling them silently disables tracing.
Notes
The prod-prune itself (900 MB → 630 MB) is a separate change; this issue is only the OTel dependency slimming on top of it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read frontend/src/lib/otel/otel.server.ts first, focusing on getNodeAutoInstrumentations, traceRequest, and traceFetch. Inspect the production dependency tree and runtime image to determine whether an explicit HTTP/undici set or no auto-instrumentation is appropriate. Done means the unnecessary OTel packages are removed while HTTP spans, outbound fetch spans, and traceparent propagation still reach the collector.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, node.js, typescript
- Domain
- devops, observability, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100