Background
In PR #71 (and issue #69), console.time()/console.timeEnd() calls in apps/public-api/src/controllers/data.controller.js were gated behind process.env.DEBUG === 'true' as a pragmatic short-term fix.
However, console.time is a dev/debug utility and is not recommended for production-grade applications for the following reasons:
- Overhead: It stores start times in an internal map using the label as the key, adds string formatting on every call.
- Concurrency bug: Concurrent requests sharing the same label (e.g.,
"insert data") overwrite each other's timer start times, producing inaccurate measurements under load.
- Not log-level aware: Cannot be silenced or routed through a log aggregation pipeline.
Goal
Replace console.time/console.timeEnd (and potentially other bare console.* calls) with a structured logger that supports log levels, so performance/debug tracing integrates cleanly with the application's observability pipeline.
Suggested options
| Use Case |
Recommended Tool |
| Quick per-request timing |
performance.now() or process.hrtime.bigint() |
| Structured logging with log levels |
pino or winston |
| Full APM/distributed tracing |
OpenTelemetry, Datadog, New Relic |
Acceptance criteria
References
Background
In PR #71 (and issue #69),
console.time()/console.timeEnd()calls inapps/public-api/src/controllers/data.controller.jswere gated behindprocess.env.DEBUG === 'true'as a pragmatic short-term fix.However,
console.timeis a dev/debug utility and is not recommended for production-grade applications for the following reasons:"insert data") overwrite each other's timer start times, producing inaccurate measurements under load.Goal
Replace
console.time/console.timeEnd(and potentially other bareconsole.*calls) with a structured logger that supports log levels, so performance/debug tracing integrates cleanly with the application's observability pipeline.Suggested options
performance.now()orprocess.hrtime.bigint()Acceptance criteria
console.time/console.timeEndcalls remain inapps/public-api/src/debug,info,warn,error)performance.now()orprocess.hrtime.bigint()with unique per-request identifiers to avoid concurrency issuesReferences