Skip to content

feat(hub): optional New Relic APM via key-gated entrypoint (closes #3) - #266

Merged
benders merged 1 commit into
mainfrom
feature/3-newrelic-monitoring
Jul 21, 2026
Merged

feat(hub): optional New Relic APM via key-gated entrypoint (closes #3)#266
benders merged 1 commit into
mainfrom
feature/3-newrelic-monitoring

Conversation

@benders

@benders benders commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Closes #3.

Adds optional New Relic APM monitoring to the hub, activated only when the operator sets NEW_RELIC_LICENSE_KEY in .env. The key is never committed, never baked into the image, and verified not to appear in logs.

How it works

  • New hub/docker-entrypoint.sh is the container CMD. With the key set, it boots the hub under the agent (node --import newrelic/esm-loader.mjs -r newrelic — the ESM app needs both hooks). Without the key it execs plain node hub/dist/server.js; zero agent code loads.
  • Path-based module specifiers because newrelic lives in hub/node_modules under the pnpm workspace layout, and cwd must stay /app so relative data-path defaults (e.g. POUTINE_PASSWORD_KEY_PATH) keep resolving.
  • Config is env-only (NEW_RELIC_NO_CONFIG_FILE=true, agent log to stdout). APM entity defaults to poutine-hub-<POUTINE_INSTANCE_ID> so federated hubs reporting to one account show as separate entities.
  • @newrelic/native-metrics + @newrelic/fn-inspect added to root pnpm.onlyBuiltDependencies for event-loop/GC/CPU metrics.
  • Zero TypeScript changes — dev/native runs never load the agent.

Verification

  • pnpm verify green, pnpm lint zero output.
  • Docker image smoke-tested both ways: no key → healthy, zero agent log lines; key set → agent 14.3.0 boots to "connecting", hub healthy, key absent from logs (grep count 0).
  • Entrypoint branch logic tested with a stub node: no key / key + instance id / key + explicit NEW_RELIC_APP_NAME.
  • Confirmed on the live hub: metrics and logs flowing in New Relic.

Docs: README operator section, docs/hub-internals.md (env rows + Observability section), example.env monitoring block.

🤖 Generated with Claude Code

Boot the hub under the New Relic Node agent only when
NEW_RELIC_LICENSE_KEY is set in the operator's .env — the key is never
committed, never baked into the image, and verified not to leak into
logs. Without the key the entrypoint execs plain `node hub/dist/server.js`
with zero agent code loaded.

- hub/docker-entrypoint.sh: key-gated exec; ESM app needs both
  `--import newrelic/esm-loader.mjs` and `-r newrelic`; path-based
  specifiers because newrelic lives in hub/node_modules (pnpm layout)
  and cwd must stay /app for relative data-path defaults
- Env-only agent config (NEW_RELIC_NO_CONFIG_FILE=true, log to stdout);
  APM entity defaults to poutine-hub-<POUTINE_INSTANCE_ID> so federated
  hubs report as separate entities
- @newrelic/native-metrics + @newrelic/fn-inspect allowed in
  pnpm.onlyBuiltDependencies for event-loop/GC/CPU metrics
- Docs: README operator section, hub-internals env rows + Observability
  section, example.env monitoring block

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@benders benders mentioned this pull request Jul 17, 2026
@benders
benders marked this pull request as ready for review July 21, 2026 06:05
@benders
benders merged commit c39560b into main Jul 21, 2026
2 checks passed
@benders
benders deleted the feature/3-newrelic-monitoring branch July 21, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Observability

1 participant