feat(mosaic): mosaic telemetry command (M6 CU-06-01..05) #417

Merged
jason.woltje merged 1 commits from feat/mosaic-telemetry into main 2026-04-05 07:06:43 +00:00
Owner

Summary

Adds the mosaic telemetry command tree (milestone M6, tasks CU-06-01 through CU-06-05).

Local half - mosaic telemetry local {status,tail,jaeger}

  • status: probes OTEL_EXPORTER_OTLP_ENDPOINT reachability via fetch (3s timeout), prints service name and export interval
  • tail: explains OTLP push model, points to Jaeger UI and docker compose logs hint
  • jaeger: prints Jaeger UI URL (respects JAEGER_UI_URL env var), --open flag opens in browser (cross-platform)

Remote half - mosaic telemetry {status,opt-in,opt-out,test,upload}

  • Remote upload is disabled by default (dry-run is the default)
  • status: shows consent state, remote endpoint, last upload timestamp
  • opt-in / opt-out: @clack/prompts consent flow, persisted to telemetry.json
  • test: synthesises fake event, dry-run by default; --upload throws via shim until server is live
  • upload: dry-run unless MOSAIC_TELEMETRY_ENDPOINT + consent + MOSAIC_TELEMETRY_DRY_RUN != 1

CU-06-01: Dependency resolution

@mosaicstack/telemetry-client-js is not yet published (404 at registry as of 2026-04-04). A forward-compat shim at packages/mosaic/src/telemetry/client-shim.ts mirrors the expected {init, captureEvent, upload, shutdown} interface. The shim throws on real-upload attempts so no false success is recorded.

Schema: {remoteEnabled, optedInAt, optedOutAt, lastUploadAt}. Persisted to $MOSAIC_HOME/telemetry.json via atomicWrite.

CU-06-05: Tests

18 Vitest tests in telemetry.spec.ts covering: command structure, opt-in/opt-out persistence, status output (both enabled and disabled + dry-run banner), and dry-run assertions (no fetch calls, no upload calls, banner visible).

Code review findings addressed

  • Blocker: Shim throws on real-upload attempts - no false lastUploadAt recorded
  • Should-fix: init() no longer resets queue - buffered events survive re-init
  • Should-fix: Windows --open uses cmd /c start instead of bare start builtin

Quality gates

  • typecheck: pass
  • lint: pass
  • format:check: pass
  • test: 143/143 pass (18 new)
## Summary Adds the **mosaic telemetry** command tree (milestone M6, tasks CU-06-01 through CU-06-05). **Local half** - mosaic telemetry local {status,tail,jaeger} - **status**: probes OTEL_EXPORTER_OTLP_ENDPOINT reachability via fetch (3s timeout), prints service name and export interval - **tail**: explains OTLP push model, points to Jaeger UI and docker compose logs hint - **jaeger**: prints Jaeger UI URL (respects JAEGER_UI_URL env var), --open flag opens in browser (cross-platform) **Remote half** - mosaic telemetry {status,opt-in,opt-out,test,upload} - Remote upload is **disabled by default** (dry-run is the default) - **status**: shows consent state, remote endpoint, last upload timestamp - **opt-in / opt-out**: @clack/prompts consent flow, persisted to telemetry.json - **test**: synthesises fake event, dry-run by default; --upload throws via shim until server is live - **upload**: dry-run unless MOSAIC_TELEMETRY_ENDPOINT + consent + MOSAIC_TELEMETRY_DRY_RUN != 1 ## CU-06-01: Dependency resolution **@mosaicstack/telemetry-client-js is not yet published** (404 at registry as of 2026-04-04). A forward-compat shim at packages/mosaic/src/telemetry/client-shim.ts mirrors the expected {init, captureEvent, upload, shutdown} interface. The shim throws on real-upload attempts so no false success is recorded. ## CU-06-04: Consent persistence Schema: {remoteEnabled, optedInAt, optedOutAt, lastUploadAt}. Persisted to $MOSAIC_HOME/telemetry.json via atomicWrite. ## CU-06-05: Tests 18 Vitest tests in telemetry.spec.ts covering: command structure, opt-in/opt-out persistence, status output (both enabled and disabled + dry-run banner), and dry-run assertions (no fetch calls, no upload calls, banner visible). ## Code review findings addressed - **Blocker**: Shim throws on real-upload attempts - no false lastUploadAt recorded - **Should-fix**: init() no longer resets queue - buffered events survive re-init - **Should-fix**: Windows --open uses cmd /c start instead of bare start builtin ## Quality gates - typecheck: pass - lint: pass - format:check: pass - test: 143/143 pass (18 new)
jason.woltje added 1 commit 2026-04-05 07:01:45 +00:00
feat(mosaic): mosaic telemetry command (CU-06-01..05)
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/push/ci Pipeline was successful
6dfc9e0e83
Add mosaic telemetry command tree covering CU-06-01 through CU-06-05.

Local half (mosaic telemetry local {status,tail,jaeger}):
- status: probes OTEL_EXPORTER_OTLP_ENDPOINT reachability via fetch
- tail: explains OTLP push model and points to Jaeger + docker compose logs
- jaeger: prints Jaeger UI URL (respects JAEGER_UI_URL), --open flag best-effort

Remote half (mosaic telemetry {status,opt-in,opt-out,test,upload}):
- Remote upload is DISABLED by default (dry-run is the default)
- opt-in / opt-out: @clack/prompts consent flow persisted to telemetry.json
- status: shows consent state, endpoint, last upload timestamp
- test: synthesises fake event, dry-run by default; --upload path throws if shim
- upload: dry-run unless MOSAIC_TELEMETRY_ENDPOINT + consent + no dry-run flag

CU-06-01: @mosaicstack/telemetry-client-js is not yet published (404).
  Uses forward-compat shim at packages/mosaic/src/telemetry/client-shim.ts
  matching the expected {init, captureEvent, upload, shutdown} interface.

CU-06-04: Consent persisted to $MOSAIC_HOME/telemetry.json via atomicWrite.
  Schema: {remoteEnabled, optedInAt, optedOutAt, lastUploadAt}.

CU-06-05: 18 Vitest tests in telemetry.spec.ts covering structure,
  opt-in/opt-out persistence, status output (both states + dry-run banner),
  and dry-run assertions (no fetch, no upload() call, banner present).

Code-review findings addressed:
- Shim throws on real-upload attempts (blocker: no false success recorded)
- init() no longer resets queue (should-fix: pending events survive re-init)
- Windows --open uses cmd /c start (should-fix: start is a shell builtin)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jason.woltje merged commit a531029c5b into main 2026-04-05 07:06:43 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#417