Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[otelfiber] Allow for disabling client IP collection in traces #1033

Merged
merged 5 commits into from
Mar 21, 2024

Conversation

gzuidhof
Copy link
Contributor

@gzuidhof gzuidhof commented Mar 18, 2024

Introduces a WithCollectClientIP(collect bool) that disables IP collection into traces.

Summary by CodeRabbit

  • New Features
    • Enhanced privacy settings with the ability to control the collection of client IP addresses in requests.
    • Middleware function now collects client IP addresses by default.
    • Attribute handling now includes client IP based on configuration.
    • Improved middleware configuration using functional parameters.

@gzuidhof gzuidhof requested a review from a team as a code owner March 18, 2024 10:15
@gzuidhof gzuidhof requested review from gaby, sixcolors, ReneWerner87 and efectn and removed request for a team March 18, 2024 10:15
Copy link
Contributor

coderabbitai bot commented Mar 18, 2024

Warning

Rate Limit Exceeded

@gzuidhof has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 40 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between aa3b5c0 and 97e7584.

Walkthrough

The recent update introduces a new feature to control the collection of client IP addresses in the otelfiber package. A boolean field, collectClientIP, has been added to the configuration, allowing users to specify whether they wish to collect client IPs. This setting is true by default. The middleware function has been adjusted accordingly to respect this new setting, enhancing privacy control and customization for developers.

Changes

Files Change Summary
config.go, fiber.go, semconv.go Added collectClientIP field to config, with a setting function. Middleware now defaults to collecting client IP based on this setting. Introduced check in semconv.go to conditionally collect client IP.
README.md Updated middleware configuration using functional parameters to include an option for collecting client IP.

🐰✨
To the code we hop and skip,
A tiny change, a giant leap.
With a flick and a flip,
Client IPs, we may or may not keep.
In the fields of fiber, we weave and stitch,
Privacy in our minds, a silent pitch. 🌟🍃

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between dfea35d and 026932f.
Files selected for processing (4)
  • otelfiber/config.go (2 hunks)
  • otelfiber/fiber.go (1 hunks)
  • otelfiber/otelfiber_test/fiber_test.go (1 hunks)
  • otelfiber/semconv.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • otelfiber/fiber.go
Additional comments: 4
otelfiber/semconv.go (1)
  • 59-63: The implementation of the conditional logic to collect the client's IP address based on the cfg.collectClientIP setting is correct and aligns with the PR's objectives. This change effectively allows users to disable the collection of client IP addresses, enhancing privacy controls.
otelfiber/config.go (2)
  • 21-21: The addition of the collectClientIP boolean field to the config struct is correctly implemented. This field enables the new feature to allow or prevent the collection of client IP addresses, aligning with the PR's objectives.
  • 101-106: The WithCollectClientIP function is correctly implemented, allowing users to configure the collection of client IP addresses. This addition follows the established pattern for configuration options in the package and is well-documented, clearly explaining its purpose and default behavior.
otelfiber/otelfiber_test/fiber_test.go (1)
  • 500-536: The TestCollectClientIP function is well-implemented, providing comprehensive test coverage for the new feature under both enabled and disabled conditions. The use of parallel test execution and dynamic test names enhances the test suite's efficiency and readability.

Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

Make sure to update the README with the new functionality

if len(clientIP) > 0 {
attrs = append(attrs, semconv.HTTPClientIPKey.String(utils.CopyString(clientIP)))
if cfg.collectClientIP {
clientIP := c.IP()
Copy link
Member

Choose a reason for hiding this comment

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

Is c.IP() ever empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unchanged from the original, if that needs to be changed probably that makes more sense in a different PR.

@gzuidhof
Copy link
Contributor Author

I wasn't sure how to update the README.. The README currently describes the config fields, but they are private as functional parameters are used instead. This PR introduces a field which is entirely private, so it can not be accessed.

@gaby
Copy link
Member

gaby commented Mar 18, 2024

I wasn't sure how to update the README.. The README currently describes the config fields, but they are private as functional parameters are used instead. This PR introduces a field which is entirely private, so it can not be accessed.

Fair!

Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

LGTM

@ReneWerner87
Copy link
Member

@gzuidhof Why is the config setting private and can only be changed using the help function?

Regardless of the answer, please also include the help function with signature and explanation in the readme

Every feature without examples or explanation gives the user fewer hints and is therefore questioned, is not known or is not used
Only transparency and hints help to avoid questions and make it usable for everyone

@gzuidhof
Copy link
Contributor Author

I'm happy for you (or anybody else) to make changes to this PR as you see fit :)

There is no mechanism for passing in your own Config object anyhow, so it doesn't really matter if it's public or private - so better to default to private was my thinking. Aside from that, with something that defaults to true setting it to false would not do anything.

The discoverability for these functional parameters are in your language server suggestions.. otelfiber.With...

Anyhow: happy for you to make any changes, just explaning my reasons :)

@ReneWerner87
Copy link
Member

ReneWerner87 commented Mar 20, 2024

okay thanks for the explanation

can you include the signatures of the With... methods and their explanation in the readme

@ReneWerner87
Copy link
Member

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 026932f and ae8f902.
Files selected for processing (1)
  • otelfiber/README.md (1 hunks)
Additional comments: 1
otelfiber/README.md (1)
  • 34-47: The documentation for the configuration options has been updated to reflect the new functional parameter style and the addition of the WithCollectClientIP option. While the changes are generally clear and informative, there are a few areas that could be improved for better readability and consistency:
  1. Ensure consistent capitalization in descriptions. For example, "specifies" should be capitalized when it starts a sentence.
  2. Add a period at the end of each description for consistency.
  3. The description for WithPort mentions "Required: If not default..." which could be clearer. Consider rephrasing to indicate that specifying the port is necessary unless the default port is used.

Additionally, consider adding a brief example or code snippet demonstrating how to disable the client IP collection using the WithCollectClientIP option. This would help users quickly understand how to apply the new feature.

@gzuidhof
Copy link
Contributor Author

Done! :)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ae8f902 and aa3b5c0.
Files selected for processing (1)
  • otelfiber/README.md (1 hunks)
Additional comments: 1
otelfiber/README.md (1)
  • 34-47: The documentation has been updated to reflect the new configuration options introduced in the PR. However, there are a few areas that could be improved for clarity and consistency:
  1. The description for WithPort mentions "Required: If not default (80 for http, 443 for https)" which could be misleading since it suggests that the port is a required parameter, whereas it actually has a default behavior. Consider rephrasing to clarify that the default port is used unless specified otherwise.

  2. The introduction of WithCollectClientIP is a significant change. It would be beneficial to include an example or a more detailed explanation of how to use this option, especially since it pertains to privacy concerns.

  3. There are minor typographical issues throughout the table, such as inconsistent use of spaces and capitalization. Ensuring consistency in formatting will improve the readability of the documentation.

  4. Given the feedback from the PR comments about enhancing user understanding through examples, it might be helpful to expand the "Example" section to demonstrate the use of the new WithCollectClientIP option, along with other configuration options.

Consider the following improvements to enhance the documentation:

  • Clarify the description of WithPort to avoid confusion about it being a required parameter.
  • Provide a detailed example or explanation for WithCollectClientIP, highlighting its importance for privacy.
  • Address typographical and formatting inconsistencies for a cleaner presentation.
  • Expand the "Example" section to include usage of the new configuration option and others, demonstrating their practical application.

@ReneWerner87
Copy link
Member

thx for the adjustment
@gzuidhof can you also check these suggestions
image

from our ai

@gzuidhof
Copy link
Contributor Author

I addressed them in this commit, I think it hasn't refreshed

@ReneWerner87
Copy link
Member

ok, thx

@ReneWerner87
Copy link
Member

@coderabbitai can you pls check the last state again

@ReneWerner87 ReneWerner87 added the ✏️ Feature New feature or request label Mar 21, 2024
Copy link
Contributor

coderabbitai bot commented Mar 21, 2024

Tip

For best results, initiate chat on the files or code changes.

@ReneWerner87, I've reviewed the latest state of the PR, specifically focusing on the README.md file and the latest commit 97e75842b91fc030fe73c70ddeef023147790aed. The README.md file provides a structured overview of the middleware implementations available in the repository, including the newly discussed Otelfiber (OpenTelemetry) middleware.

However, based on the provided output, it appears that the specific details regarding the With... methods and their explanations, as requested, are not directly visible in the provided README.md content. It's possible that these details are included within the linked ./otelfiber/README.md file or another part of the documentation not captured in the output.

To ensure comprehensive documentation and transparency for users, it might be beneficial to verify that the otelfiber README or another appropriate section includes:

  • Clear explanations of the With... methods, including WithCollectClientIP(collect bool).
  • Examples demonstrating how to use these methods to configure the middleware, especially regarding the client IP collection feature.

This approach will help in enhancing discoverability and usability of the new features introduced in the PR, aligning with the objectives of providing users with more control and flexibility.

If further detailed review or actions are needed, please let me know! 🐇

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Fetch the latest commit hash from the PR branch
git log -n 1 --pretty=format:"%H"

# Fetch the README file content to review the changes made
cat README.md

Length of output: 5304

@ReneWerner87
Copy link
Member

ok, we improve the readme later with examples -> follow up PR ?

@ReneWerner87 ReneWerner87 merged commit 889e337 into gofiber:main Mar 21, 2024
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants