mock: true flag that silently no-ops all calls in dev and test.
The MetricsType interface
Every metrics provider satisfies the same contract:
Why
StatsD is a widely supported, UDP-based metrics protocol with near-zero overhead. Thehot-shots client supports Datadog DogStatsD extensions (tags, histograms) and runs equally well against a local Telegraf agent or a cloud service like Datadog. The mock: true option means you don’t need a StatsD server running in dev at all.
Setup
- In
apps/backend/package.json, ensure"tooling-metrics-statsd": "workspace:*"is listed underdependencies. - Run
make pnpm-lockfile-updatethenmake pnpm-install. - In
development.tsandtest.ts, use mock mode: - In
production.ts, point at your StatsD agent: - In your production environment, set:
- Run
make test module=tooling-metrics-statsdandmake test module=backend.
Emitting metrics
Gotchas
- StatsD uses UDP — metric sends are fire-and-forget and will not throw on failure. Errors are routed to
tools.logger.errorvia theerrorHandlerinbuildStatsdClient. globalTagsare merged into every metric. Keep them low-cardinality (env,service) — never put per-request data in global tags.mock: truemust be removed in production. If you accidentally leave it on, all metrics are silently swallowed — your dashboards will appear empty.- Never omit
hostandportin production.hot-shotsdefaults tolocalhost:8125, which silently drops metrics if no agent is listening there.
What’s next?
- Configuration — switching pluggable tool implementations.
- Tooling system — how loaders and workspace packages fit together.