Commit Graph

4 Commits

  • fix(logging): capture streaming TTFB on first chunk and make timestamps required
    - Add firstChunkTimestamp field to ResponseWriterWrapper for sync capture
    - Capture TTFB in Write() and WriteString() before async channel send
    - Add SetFirstChunkTimestamp() to StreamingLogWriter interface
    - Make requestTimestamp/apiResponseTimestamp required in LogRequest()
    - Remove timestamp capture from WriteAPIResponse() (now via setter)
    - Fix Gemini handler to set API_RESPONSE_TIMESTAMP before writing response
    
    This ensures accurate TTFB measurement for all streaming API formats
    (OpenAI, Gemini, Claude) by capturing timestamp synchronously when
    the first response chunk arrives, not when the stream finalizes.
  • fix(logging): add API response timestamp and fix request timestamp timing
    Previously:
    - REQUEST INFO timestamp was captured at log write time (not request arrival)
    - API RESPONSE had NO timestamp at all
    
    This fix:
    - Captures REQUEST INFO timestamp when request first arrives
    - Adds API RESPONSE timestamp when upstream response arrives
    
    Changes:
    - Add Timestamp field to RequestInfo, set at middleware initialization
    - Set API_RESPONSE_TIMESTAMP in appendAPIResponse() and gemini handler
    - Pass timestamps through logging chain to writeNonStreamingLog()
    - Add timestamp output to API RESPONSE section
    
    This enables accurate measurement of backend response latency in error logs.
  • refactor(config): migrate to SDKConfig and streamline proxy handling
    - Replaced `config.Config` with `config.SDKConfig` across components for simpler configuration management.
    - Updated proxy setup functions and handlers to align with `SDKConfig` improvements.
    - Reorganized handler imports to match new SDK structure.