Skip to content

feat(sandbox): telemetry on installed deps per sandbox install - #4269

Merged
pedrofrxncx merged 3 commits into
mainfrom
feat/sandbox-dep-install-metrics
Jul 2, 2026
Merged

pedrofrxncx merged 3 commits into
mainfrom
feat/sandbox-dep-install-metrics

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds observability-only telemetry on which dependencies get installed in each sandbox, so the team can decide which packages to pre-bake into the sandbox image. No change to install behavior; no shared cache.

After a successful install (stepInstall, exit 0), the daemon reads the flattened installed dependency set and emits it. Install behavior, gating, and skip logic are untouched — the emit is a fire-and-forget, best-effort side effect that never throws.

What it emits

  • One structured JSON log line per successful install (msg: "sandbox.install.deps") with: bootId, packageManager, repoName, branch, dependencyCount, and dependencies: [{ name, version }]. Aggregated downstream in VictoriaLogs.
  • Low-cardinality metrics on the existing link-daemon meter (no new OTel dep): sandbox_install_total counter and sandbox_install_dependency_count histogram, labeled only by package_manager.
  • Package name/version are NEVER metric labels — that lives only in the log line, to avoid a Prometheus cardinality explosion.

How the dep set is read

PM-agnostic: walks the on-disk node_modules via Bun.Glob("**/package.json") (followSymlinks: false, dot: true) and collects {name, version}, deduped. This covers npm / pnpm / yarn / bun with one code path — pnpm's real package dirs under .pnpm/ are picked up while its top-level symlinks are skipped, so every PM yields the same flattened set. A small filter (isPackageManifest, unit-tested) rejects fixture/sample package.json files shipped inside packages. Chose reading node_modules over parsing four different lockfile formats: smaller diff, uniform coverage, and it reflects what actually landed on disk.

  • deno is not covered — it has no install step (auto-fetch), so the emit is never reached for it. All PMs that actually run an install are covered.

Where it's hooked

packages/sandbox/daemon/setup/orchestrator.ts → stepInstall(), right after markInstallSucceeded() on the exit-0 path. Identifiers come from what's already in that code path: DAEMON_BOOT_ID (the daemon's existing log correlation key) + repo name/branch from config. New helper: packages/sandbox/daemon/setup/dep-metrics.ts.

Testing

  • bun run check (typecheck) clean
  • bun test daemon/setup — existing orchestrator/clone tests pass; added dep-metrics.test.ts for the manifest filter
  • bun run lint — 0 errors

🤖 Generated with Claude Code


Summary by cubic

Adds observability-only telemetry that records which dependencies were installed after a successful sandbox install. No changes to install behavior or caching.

  • New Features

    • Emits one JSON log line per successful install (msg: "sandbox.install.deps") with bootId, packageManager, repoName, branch, dependencyCount, and dependencies: [{ name, version }].
    • PM-agnostic: scans on-disk node_modules to build a deduped dep set (works for npm/pnpm/yarn/bun); excludes fixture/sample manifests via a small, tested filter.
    • Hooked into stepInstall() after a successful install; fire-and-forget and never throws.
  • Bug Fixes

    • Removed no-op install metrics (counter/histogram); only the stdout JSON log line is emitted.

Written for commit 363a4f3. Summary will update on new commits.

Review in cubic

Log the flattened name@version dependency set (read from on-disk
node_modules, PM-agnostic) as one JSON line per successful install so the
team can decide which packages to pre-bake into the sandbox image. Adds
low-cardinality metrics (install counter + dependency-count histogram);
package name/version are NEVER metric labels.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 2, 2026 20:55
@pedrofrxncx
pedrofrxncx disabled auto-merge July 2, 2026 20:59
The daemon has no MeterProvider/exporter (only @opentelemetry/api), and
sandbox pods can't reach an in-cluster OTLP collector (egress locked to
53/443), so the counter/histogram never left the process. The stdout JSON
log line is the only channel that reaches VictoriaLogs.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 2, 2026 21:06
@pedrofrxncx
pedrofrxncx disabled auto-merge July 2, 2026 21:06
@pedrofrxncx
pedrofrxncx merged commit f6a4f42 into main Jul 2, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the feat/sandbox-dep-install-metrics branch July 2, 2026 21:11
decocms Bot pushed a commit that referenced this pull request Jul 2, 2026
PR: #4269 feat(sandbox): telemetry on installed deps per sandbox install
Bump type: minor

- @decocms/sandbox (packages/sandbox/package.json): 1.8.3 -> 1.9.0

Deploy-Scope: both
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.

1 participant