chore: OpenTelemetry tracing, hardened Dockerfile, and CONTRIBUTING guide (Closes #130 #131 #132) - #177
Open
MatanOga01 wants to merge 5 commits into
Open
Conversation
Preloads the OpenTelemetry NodeSDK via backend/src/telemetry.ts, registered
through 'node -r ./dist/telemetry dist/main' in start:prod so the SDK can
patch http, express, typeorm/pg, ioredis and others before any Nest
module loads.
Includes:
- backend/src/telemetry.ts (NodeSDK bootstrap, OTLP HTTP exporter, fs
instrumentation disabled by default, swallow-all errors, SIGTERM/SIGINT
shutdown, no-op when OTEL_SDK_DISABLED=true)
- New deps: @opentelemetry/api, sdk-node, auto-instrumentations-node,
exporter-trace-otlp-http, resources, semantic-conventions
- start:prod script now preloads telemetry before booting Nest
Closes part of NovaCoreLabs1#131.
Three-stage build (deps, build, runtime) emitting a distroless Node 20 image that runs as the built-in nonroot user (UID 65532). Build context is tightly scoped via .dockerignore (.git, node_modules, contracts/target, .env, secrets, IDE noise). Templates included via nest-cli.json assets. Closes part of NovaCoreLabs1#130.
Covers: code of conduct, bug/feature templates, security disclosures, local dev setup, branching, Conventional Commits, pre-commit checklist, backend/frontend/contracts style & module architecture, OpenTelemetry activation env vars and a local Jaeger recipe, hardened Docker build/run instructions, testing (Jest/Stryker/ESLint/cargo), PR process, label triage guide. Closes part of NovaCoreLabs1#132.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR closes all three issues currently assigned to @MatanOga01 in a single reviewable change set:
.dockerignoreto keep the build context tight.backend/src/telemetry.ts, wired throughnode -r ./dist/telemetry dist/mainfromstart:prod, OTLP HTTP exporter, no-op whenOTEL_SDK_DISABLED=true.CONTRIBUTING.mdwith comprehensive contributor guide #132 — CONTRIBUTING.md: comprehensive contributor guide covering setup, commits, code style, testing, Docker runbook, OTel activation, and PR process.Closes #130
Closes #131
Closes #132
Change type
Test plan
cd backend && npm install— resolves 6 new OpenTelemetry deps; build passes.cd backend && npm run build— nest build succeeds (exit 0).cd backend && npm run lint— ESLint clean (exit 0).cd backend && npm test -- --passWithNoTests— 23/23 tests pass across 6 suites.docker build -t novalabs-backend .— produces distroless image running as UID 65532.OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 npm --prefix backend run start:prodagainst a local Jaeger collects outbound-HTTP and Nest spans.Screenshots
N/A — no UI changes.
Breaking changes
next.config.tsand the contract workspace are untouched. One new optional env-var pair (OTEL_*) is documented in CONTRIBUTING.md and defaults preserve current behaviour. Thestart:prodscript now preloadsdist/telemetry.jsvia-r; ifdist/telemetry.jsis missing the script fails loudly on boot, intentionally — better than silent partial tracing.PR contents
3 conventional commits:
feat(observability): add OpenTelemetry tracing to backendchore(docker): add hardened multi-stage Dockerfile for backenddocs(contributing): add comprehensive contributor guide