Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Do not move metrics you must keep onto a sampled log channel
Attaching business or ingest counters to a request line that sampling can drop silently loses most of the data, and the loss is invisible because the surviving records still look correct.
Bad example
| 1 | // Emitted only if shouldSample() passes - 5% in production |
| 2 | logger.add({ "data.source": source, "data.itemCount": items.length }); |
Explanation (EN)
The counters ride on the sampled canonical request line, so most ingest records never reach the aggregator and every total is silently wrong.
Objašnjenje (HR)
Brojaci se voze na uzorkovanoj kanonskoj liniji zahtjeva, pa vecina zapisa nikad ne stigne do agregatora i svaki je zbroj tiho pogresan.
Good example
| 1 | // Always written, independent of the request line's sample rate |
| 2 | emitInfo("ingest.batch", { source, itemCount: items.length }); |
Explanation (EN)
The metric uses an unsampled channel, so counts stay complete regardless of how request logging is tuned.
Objašnjenje (HR)
Metrika koristi kanal bez uzorkovanja, pa brojevi ostaju potpuni bez obzira na to kako je podeseno logiranje zahtjeva.
Notes (EN)
Sampling is a cost control for high-volume request traces, not for the handful of records you actually count on. Decide per field which channel it belongs to.
Bilješke (HR)
Uzorkovanje je kontrola troska za tragove zahtjeva velikog volumena, a ne za sacicu zapisa na koje se stvarno oslanjas. Za svako polje odluci kojem kanalu pripada.