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

feat(tracing): add http.client_ip attribute #10723

Merged
merged 8 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@
- Request and response buffering options are now enabled for incoming HTTP 2.0 requests too.
Thanks [@PidgeyBE](https://github.com/PidgeyBE) for contributing this change.
[#10595](https://github.com/Kong/kong/pull/10595)
[#10204](https://github.com/Kong/kong/pull/10204)
[#10204](https://github.com/Kong/kong/pull/10204)
- Add `KONG_UPSTREAM_DNS_TIME` to `kong.ctx` so that we can record the time it takes for DNS
resolution when Kong proxies to upstream.
[#10355](https://github.com/Kong/kong/pull/10355)
- Tracing: rename spans to simplify filtering on tracing backends.
[#10577](https://github.com/Kong/kong/pull/10577)
- Support timeout for dynamic log level
[#10288](https://github.com/Kong/kong/pull/10288)
- Added new span attribute `http.client_ip` to capture the client IP when behind a proxy.
[#10723](https://github.com/Kong/kong/pull/10723)

#### Admin API

Expand Down
1 change: 1 addition & 0 deletions kong/tracing/instrumentation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ function _M.request(ctx)
["http.host"] = host,
["http.scheme"] = scheme,
["http.flavor"] = http_flavor,
["http.client_ip"] = client.get_forwarded_ip(),
["net.peer.ip"] = client.get_ip(),
},
})
Expand Down
1 change: 1 addition & 0 deletions spec/03-plugins/37-opentelemetry/04-exporter_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ for _, strategy in helpers.each_strategy() do
local attr = span.attributes
sort_by_key(attr)
assert.same({
{ key = "http.client_ip", value = { string_value = "127.0.0.1", value = "string_value" } },
{ key = "http.flavor", value = { string_value = "1.1", value = "string_value" } },
{ key = "http.host", value = { string_value = "0.0.0.0", value = "string_value" } },
{ key = "http.method", value = { string_value = "GET", value = "string_value" } },
Expand Down