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

Gin exporter: support reading Client IP from custom headers (and make sure proxy is trusted) #6095

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

ItalyPaleAle
Copy link

@ItalyPaleAle ItalyPaleAle commented Sep 8, 2024

With Gin, it's possible to configure the server to read the Client IP from custom headers; examples include X-Real-Ip or CF-Connecting-IP. This PR makes it possible to set as span attribute the same IP that Gin reads.

Additionally, it makes sure that headers such as "X-Forwarded-For" are used only if Gin is configured to trust the upstream server

… sure proxy is trusted)

With Gin, it's possible to configure the server to read the Client IP from custom headers; examples include `X-Real-Ip` or `CF-Connecting-IP`. This PR makes it possible to set as span attribute the same IP that Gin reads.

Additionally, it makes sure that headers such as "X-Forwarded-For" are used only if Gin is configured to trust the upstream server

PS: Also fixed unit tests, where there were assertions inside handlers, which are executed in separate goroutines
@ItalyPaleAle ItalyPaleAle requested a review from a team September 8, 2024 21:34
Copy link

linux-foundation-easycla bot commented Sep 8, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@dmathieu
Copy link
Member

dmathieu commented Sep 9, 2024

PS: Also fixed unit tests, where there were assertions inside handlers, which are executed in separate goroutines

Could you split that into another PR, to make things easier to review?

@ItalyPaleAle
Copy link
Author

PS: Also fixed unit tests, where there were assertions inside handlers, which are executed in separate goroutines

Could you split that into another PR, to make things easier to review?

Done

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.1%. Comparing base (aaa6d68) to head (666002a).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #6095   +/-   ##
=====================================
  Coverage   67.0%   67.1%           
=====================================
  Files        194     194           
  Lines      12658   12691   +33     
=====================================
+ Hits        8492    8523   +31     
- Misses      3888    3889    +1     
- Partials     278     279    +1     
Files with missing lines Coverage Δ
...stful/otelrestful/internal/semconvutil/httpconv.go 96.1% <100.0%> (+<0.1%) ⬆️
...hub.com/emicklei/go-restful/otelrestful/restful.go 100.0% <100.0%> (ø)
...ation/github.com/gin-gonic/gin/otelgin/gintrace.go 82.6% <100.0%> (+0.4%) ⬆️
...gonic/gin/otelgin/internal/semconvutil/httpconv.go 96.1% <100.0%> (+<0.1%) ⬆️
...rilla/mux/otelmux/internal/semconvutil/httpconv.go 96.1% <100.0%> (+<0.1%) ⬆️
...trumentation/github.com/gorilla/mux/otelmux/mux.go 89.4% <100.0%> (ø)
...entation/github.com/labstack/echo/otelecho/echo.go 100.0% <100.0%> (ø)
...ack/echo/otelecho/internal/semconvutil/httpconv.go 96.1% <100.0%> (+<0.1%) ⬆️
...on.v1/otelmacaron/internal/semconvutil/httpconv.go 96.1% <100.0%> (+<0.1%) ⬆️
...ntation/gopkg.in/macaron.v1/otelmacaron/macaron.go 92.3% <100.0%> (ø)
... and 4 more

... and 1 file with indirect coverage changes

Copy link
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

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

This will need a changelog entry.

CHANGELOG.md Outdated Show resolved Hide resolved
@ItalyPaleAle ItalyPaleAle requested a review from a team as a code owner September 20, 2024 14:51
@ItalyPaleAle
Copy link
Author

@dmathieu is this PR ready to be merged?

@dmathieu
Copy link
Member

PRs need two approvals.

CHANGELOG.md Outdated Show resolved Hide resolved
@ItalyPaleAle
Copy link
Author

PRs need two approvals.

@dmathieu is there a way I get a review/approval from another person?

@dmathieu
Copy link
Member

dmathieu commented Oct 7, 2024

Ping @open-telemetry/go-approvers for review.

Note that this instrumentation has no owner, and is therefore in the process of being deprecated/removed unless someone steps up to own it (which also explains the lack of reviews).
#6190

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