Skip to content

Add per-route Server-Timing headers with PII-safe phase breakdown #454

Description

@thlpkee20-wq

Description

Add Server-Timing headers exposing phase timings (auth, db, external) for instrumented routes, gated by env flag for non-prod, to speed up frontend performance triage without leaking PII.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Relevant code: src/middleware/metricsMiddleware.ts, src/middleware/requestLog.ts
  • Header must be omitted on prod unless X-Debug-Token matches

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b obs/server-timing
  • Implement changes
    • Add phase wrapper utility recording timings into request context
    • Emit Server-Timing header from response finalize
    • Gate by env and debug-token middleware
  • Validate security and correctness assumptions

Test and commit

  • Run tests
    • npm test
  • Cover edge cases
    • Disabled by default, very-slow phase, missing phase
  • Include test output and notes

Example commit message

obs: Server-Timing breakdown for instrumented routes

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions