Stop writing three log events per nemar-api request

Open
#2,634 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Read backend/src/middleware/access-log.ts and its mount in backend/src/index.ts:155, then review sampling settings in backend/wrangler-sccn.toml:257-270 and rejection logging in backend/src/routes/data.ts:122-148. Check backend/test/access-log.test.ts for the existing logger expectation. Decide how to preserve diagnosable failures while reducing routine logs; done means comparable-traffic ingestion drops by at least two thirds and a deliberately failing request remains findable.

Written by the indexing model from the issue text.

Description

Part of #2633.

Every nemar-api request writes three Workers Logs events: the platform invocation log (about 4.3 KB each, eventSize 4348 on a sampled data request) and two lines from Hono's logger (<-- GET ... and --> GET ... 302 692ms) printed by accessLogger() in backend/src/middleware/access-log.ts, mounted for every request in backend/src/index.ts:155. The invocation log already records method, URL, status, wall and CPU time, so the two logger lines add nothing. backend/wrangler-sccn.toml:257-270 keeps head_sampling_rate = 1 and invocation_logs = true; its comment assumes "low QPS ... under the 200k events/day" cap, while data.nemar.org now serves 1M to 9M requests a day (53.5M on 2026-11-24).

November: 155.6M log events, $81.60. Current cycle: about 1.5 GB/day ingested under the volume pricing live since 2026-12-01 (50 GB/cycle included, then $0.25/GB).

Proposed: stop the per-request logger lines in production (keep the redaction for anything still logged), sample production logs (for example head_sampling_rate = 0.2), and quiet the per-request console.log rejections in backend/src/routes/data.ts:122-148, which fire once per bad id. Keep errors diagnosable (decide whether errors need a separate path, such as Analytics Engine counters, when sampled). backend/test/access-log.test.ts pins that the logger is mounted; update it with the decision.

Acceptance: observability ingestion per day in Billing falls by at least two thirds at comparable traffic; a deliberately failing request is still findable.

Dominant language
TypeScript
Stars
0
Forks
1
Avg merge
4h 48m
Merged PRs (30d)
468

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nemarOrg/nemar-cli

All issues in nemarOrg/nemar-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.