Skip to content

Conversation

@samber
Copy link
Owner

@samber samber commented Jan 6, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 6, 2026 16:07
@samber samber merged commit 464d7f3 into main Jan 6, 2026
16 checks passed
@codecov
Copy link

codecov bot commented Jan 6, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link

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

This PR introduces optional client IP tracking functionality to support PII/GDPR compliance scenarios, allowing users to disable IP address logging when needed. The changes also include refactoring of the configuration initialization and performance optimizations through pre-allocated slice capacities.

  • Added a new WithClientIP configuration field to control whether client IP addresses are logged (defaults to true)
  • Refactored configuration initialization by introducing a DefaultConfig() function for better code reusability
  • Optimized memory allocations by pre-allocating slice capacities for attributes

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
middleware.go Adds WithClientIP config field, creates DefaultConfig() function, implements conditional IP logging, and optimizes slice allocations
README.md Updates documentation to include the new WithClientIP configuration field
.github/workflows/test.yml Disables fail-fast for the test matrix to allow all Go version tests to complete

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


baseAttributes := []slog.Attr{}
baseAttributes := make([]slog.Attr, 0, 3)
requestAttributes := make([]slog.Attr, 0, 14)
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The pre-allocated capacity for requestAttributes is set to 14, but the initial append only adds 8 attributes. The actual number of attributes varies depending on configuration flags (WithClientIP, WithRequestBody, WithRequestHeader, WithUserAgent), and the X-Forwarded-For header presence. Consider adjusting the capacity to better match the typical case, or use a more conservative estimate that accounts for the most common configuration.

Suggested change
requestAttributes := make([]slog.Attr, 0, 14)
requestAttributes := make([]slog.Attr, 0, 8)

Copilot uses AI. Check for mistakes.
slog.String("ip", ip),
)
}

Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

There is trailing whitespace on this line (tab character after the closing parenthesis). This should be removed for consistency with the codebase formatting.

Suggested change

Copilot uses AI. Check for mistakes.
WithResponseHeader bool
WithSpanID bool
WithTraceID bool
WithClientIP bool
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The README has been updated to include the new WithClientIP field in the Config struct documentation, but there's no explanation of what this field does, what its default value is, or when users might want to set it to false (e.g., for PII/GDPR compliance). Consider adding a usage example or documentation section that explains this privacy-focused feature, especially given the PR title mentions "optional IP tracking".

Copilot uses AI. Check for mistakes.

Filters: []Filter{},
})
return NewWithConfig(logger, Config{ })
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The New() function is passing an empty Config{} struct instead of using DefaultConfig(). This means all configuration fields will be set to their zero values, which differs from the intended default behavior. For example, WithRequestID should default to true and WithClientIP should default to true according to DefaultConfig(), but they will be false with an empty struct. This will break existing users who expect the default configuration when calling New().

Suggested change
return NewWithConfig(logger, Config{ })
return NewWithConfig(logger, DefaultConfig())

Copilot uses AI. Check for mistakes.
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