Skip to content

Stop emitting legacy metric/status logs#668

Draft
silvadenisaraujo wants to merge 3 commits into
masterfrom
aerie/stop-emitting-legacy-metric-status-logs
Draft

Stop emitting legacy metric/status logs#668
silvadenisaraujo wants to merge 3 commits into
masterfrom
aerie/stop-emitting-legacy-metric-status-logs

Conversation

@silvadenisaraujo

@silvadenisaraujo silvadenisaraujo commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

CI note: All node-ci-v2 pipeline tasks pass (install, build, test, lint, scan). The SonarQube Code Analysis gate fails, but it is not a required check (no branch-protection required checks / rulesets on master) and its result (315 new issues, ~30% coverage on new code, D reliability rating) is essentially unchanged from the spec-only diff (30.10% → 30.20%). Those figures reflect Sonar's broad "new code" baseline across the branch, not this 3-file net-removal change; resolving them would require touching hundreds of unrelated files, which is out of scope for this task. This was anticipated in the approved spec (§ "Sonar quality gate on the spec PR"). The mandated gate — yarn test, yarn lint, yarn build — passes locally and in CI.

Summary

Production status tracking currently emits one __VTEX_IO_LOG entry with type: metric/status per flushed legacy metric on every cluster-wide /_status tick, producing ~10M indexed log entries per hour for a stream that is no longer used. This work removes the console-log export from logStatus/trackStatus() in src/service/worker/runtime/statusTrack.ts while keeping the global.metrics.statusTrack() flush (result discarded) and the HttpAgentSingleton.updateHttpAgentMetrics() diagnostics gauge refresh, so the status endpoint, cluster broadcast/IPC flow, Prometheus /metrics, billing/app logs, and diagnostics metrics all stay unchanged.

Spec

Status: ✅ approved & implemented.

See specs/stop-emitting-legacy-metric-status-logs.md.

Implementation

  • Calling trackStatus() emits no console.log entry containing type: metric/status. — Deleted the private logStatus helper (the only source of that line) and removed the forEach(...logStatus) loop from trackStatus(). Test spies on console.log and asserts no call and no metric/status string.
  • Calling trackStatus() invokes global.metrics.statusTrack() exactly once so legacy metric batches are still flushed.trackStatus() now calls global.metrics.statusTrack() once and discards the return value (kept purely for its flushing side effect). Test mocks global.metrics.statusTrack and asserts exactly one call.
  • Calling trackStatus() invokes HttpAgentSingleton.updateHttpAgentMetrics() exactly once so diagnostics HTTP-agent gauges continue to update. — Kept the call as-is. Test spies the static method and asserts exactly one call.
  • A focused automated test covers the three trackStatus() behaviors above. — New src/service/worker/runtime/statusTrack.test.ts (3 tests, jest + ts-jest, mirrors HttpAgentSingleton.test.ts conventions).
  • The /_status route and broadcastStatusTrack/statusTrack IPC flow remain unchanged. — No edits to statusTrackHandler, broadcastStatusTrack, isStatusTrack, isStatusTrackBroadcast, src/service/master.ts, or src/service/worker/index.ts.
  • Prometheus /metrics, __VTEX_IO_LOG application logs, and __VTEX_IO_BILLING process-time logs remain unchanged. — None of those code paths were touched; only the metric/status export inside trackStatus() was removed. Prom-client cluster aggregation is independent of this legacy export.
  • docs/METRICS_CATALOG.md no longer describes MetricsAccumulator values as console.log exports and documents that status ticks flush and discard them. — Updated the visual-summary node and the ### MetricsAccumulator section (and the architecture-overview line) to state the values are accumulated in memory and flushed & discarded on each /_status tick by trackStatus(), no longer exported via console.log.
  • yarn test, yarn lint, and yarn build pass. — All three pass locally (full suite: 209 passed, 24 skipped; lint only pre-existing warnings; build clean).

Cleanup / notes

  • Removed imports only used by logStatus (ACCOUNT, APP, PRODUCTION, WORKSPACE). LINKED is kept — still used by statusTrackHandler. EnvMetric/NamedMetric/StatusTrack type exports are kept (imported by MetricsAccumulator.ts).
  • No deviations from the approved spec.

Made with Cursor

Aerie status

Implementation complete

  • Last completed step: implement
  • Updated: 2026-07-17T18:08:48.234Z
  • Branch: aerie/stop-emitting-legacy-metric-status-logs
  • Spec: specs/stop-emitting-legacy-metric-status-logs.md

Acceptance criteria

  • Calling trackStatus() emits no console.log entry containing type: metric/status.
  • Calling trackStatus() invokes global.metrics.statusTrack() exactly once so legacy metric batches are still flushed.
  • Calling trackStatus() invokes HttpAgentSingleton.updateHttpAgentMetrics() exactly once so diagnostics HTTP-agent gauges continue to update.
  • A focused automated test covers the three trackStatus() behaviors above.
  • The /_status route and broadcastStatusTrack/statusTrack IPC flow remain unchanged.
  • Prometheus /metrics, __VTEX_IO_LOG application logs, and __VTEX_IO_BILLING process-time logs remain unchanged.
  • docs/METRICS_CATALOG.md no longer describes MetricsAccumulator values as console.log exports and documents that status ticks flush and discard them.
  • yarn test, yarn lint, and yarn build pass.

Internal task id: task-ac9cfeec (bean)

Specification only (no implementation) for removing the legacy
type: metric/status console.log export from trackStatus() while
preserving the flush and diagnostics gauge side effects.

Internal task id: task-ac9cfeec (bean)

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread specs/stop-emitting-legacy-metric-status-logs.md
silvadenisaraujo and others added 2 commits July 17, 2026 12:28
Clarify that the /_status IPC flow is shared infrastructure (diagnostics
gauge refresh + accumulator flush/onFlushMetrics), so only the console.log
export is removed and the IPC path is kept. Add Sonar quality-gate note.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the console.log export (`type: metric/status` / `__VTEX_IO_LOG`)
from `trackStatus()`. The status-track route, master/worker IPC flow,
Prometheus `/metrics`, billing logs, and diagnostics gauges are unchanged.

`global.metrics.statusTrack()` is still called (result discarded) so
legacy metric batches keep being flushed and `onFlushMetrics` callbacks
keep running; `HttpAgentSingleton.updateHttpAgentMetrics()` still refreshes
diagnostics HTTP-agent gauges.

Adds focused `statusTrack.test.ts` and updates `docs/METRICS_CATALOG.md`.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonar-workflows

Copy link
Copy Markdown

Failed Quality Gate failed

  • 315 New Issues (is greater than 0)
  • 30.20% Coverage on New Code (is less than 75.00%)
  • 0.00% Security Hotspots Reviewed on New Code (is less than 100.00%)
  • D Reliability Rating on New Code (is worse than A)

Project ID: node-vtex-api

View in SonarQube

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