Skip to content

Log response size and duration#565

Merged
irees merged 1 commit intomainfrom
log-duration
Jan 30, 2026
Merged

Log response size and duration#565
irees merged 1 commit intomainfrom
log-duration

Conversation

@irees
Copy link
Copy Markdown
Contributor

@irees irees commented Jan 30, 2026

Adds response duration and response size tracking to the HTTP metering middleware.

Changes

  • Added Duration (time.Duration) and ResponseSize (int64) fields to MeterEvent struct
  • Updated responseWriterWrapper to track response body size by intercepting Write calls
  • Updated WithMeter middleware to measure request duration and capture response size

These metrics are recorded alongside existing HTTP-specific fields (StatusCode, Success) for request observability.

@irees irees marked this pull request as ready for review January 30, 2026 00:47
Copilot AI review requested due to automatic review settings January 30, 2026 00:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds request duration and response size information to HTTP metering so downstream meter providers can observe these metrics per request.

Changes:

  • Extended MeterEvent to include Duration and ResponseSize fields for recording request timing and body size.
  • Updated the WithMeter middleware to time each request, wrap the ResponseWriter to track bytes written, and populate the new fields on the emitted MeterEvent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
server/meters/mw.go Times handler execution and wraps the ResponseWriter to capture status, duration, and response body size, passing these into the metering event.
server/meters/meters.go Extends the MeterEvent struct with duration and response size fields so meter providers can consume the new metrics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@irees irees merged commit 2c3cf53 into main Jan 30, 2026
14 checks passed
@irees irees deleted the log-duration branch January 30, 2026 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants