Skip to content

Clarify meaning of latency headers in proxy page and update kong.log PDK latencies field #8792

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

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

Conversation

gruceo
Copy link
Contributor

@gruceo gruceo commented May 19, 2025

Description

This update improves the documentation for the X-Kong-Proxy-Latency and X-Kong-Upstream-Latency headers. It clarifies that X-Kong-Proxy-Latency measures only Kong's internal processing time, excluding upstream and third-party I/O latencies (such as Redis, DNS, HTTP calls, and socket calls). It also explains that latency headers are reported during the header_filter phase, which may be too early in cases where body processing is significant. As a result, the reported latency values might not reflect the full request lifecycle. For more comprehensive latency data, users are advised to use Active Tracing in Konnect, the Analytics feature in Konnect, a metrics plugin (e.g., Prometheus), or a logging plugin (e.g., http-log).

We also added information about the new advanced_latency_tokens configuration option, which allows users to include additional latency tokens in the response headers. This feature is useful for those who want to customize the latency information returned in the response.

Additionally, we updated the documentation in kong.log.md to accurately describe all latency fields available in the latencies table returned by kong.log.serialize() such as receive, client, third_party, dns, redis, http_client, and socket as described in kong-ee. The update clarifies the meaning of each field and references the configuration option for advanced latency metrics. This improves clarity for plugin developers and users integrating with logging plugins, ensuring they understand the full set of latency metrics available for observability and troubleshooting.

Fix KAG-6992, DOCU-4190

Testing instructions

Preview link: https://deploy-preview-8792--kongdocs.netlify.app/

Checklist

This update improves the documentation for the X-Kong-Proxy-Latency and X-Kong-Upstream-Latency headers. It clarifies that X-Kong-Proxy-Latency measures only Kong's internal processing time, excluding upstream and third-party I/O latencies (such as Redis, DNS, HTTP calls, and socket calls). It also explains that latency headers are reported during the header_filter phase, which may be too early in cases where body processing is significant. As a result, the reported latency values might not reflect the full request lifecycle. For more comprehensive latency data, users are advised to use Active Tracing in Konnect, the Analytics feature in Konnect, a metrics plugin (e.g., Prometheus), or a logging plugin (e.g., http-log).

We also added information about the new advanced_latency_tokens configuration option, which allows users to include additional latency tokens in the response headers. This feature is useful for those who want to customize the latency information returned in the response.

Fix KAG-6992, DOCU-4190
@gruceo gruceo requested a review from a team as a code owner May 19, 2025 18:45
@gruceo gruceo added the review:copyedit Request for writer review. label May 19, 2025
Copy link

netlify bot commented May 19, 2025

Deploy Preview for kongdocs ready!

Name Link
🔨 Latest commit dc0e889
🔍 Latest deploy log https://app.netlify.com/projects/kongdocs/deploys/683712612cea090008a90187
😎 Deploy Preview https://deploy-preview-8792--kongdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
9 paths audited
Performance: 92 (🟢 up 1 from production)
Accessibility: 93 (no change from production)
Best Practices: 98 (🟢 up 8 from production)
SEO: 98 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@gruceo gruceo requested review from veenaraja, samugi and brentos May 19, 2025 18:46
Copy link
Contributor

@veenaraja veenaraja left a comment

Choose a reason for hiding this comment

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

Other than the missing advanced_latency_token in the config reference page , LGTM.

@@ -1012,6 +1019,8 @@ successfully processed by such `body_filter` hooks is sent back to the client.
You can find more information about the `body_filter` hook in the [Plugin
development guide][plugin-development-guide].

{{site.base_gateway}} also supports `advanced_latency_tokens` to expose more detailed timing headers such as total latency, third-party latency, and client latency. For details, see the [configuration-reference].
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no mentioned of this advanced_latency_tokens in the config reference page. CAn you include how it need to be set right here?
Is it advanced_latency_tokens=true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be sourced from our kong.conf file. It's a value from the KONG_HEADERS config option.

@lena-larionova lena-larionova self-assigned this May 27, 2025
@lena-larionova lena-larionova added the do not merge Issues/ PRs whose changes should not be merged at this time label May 27, 2025
@gruceo gruceo changed the title Clarify meaning and timing of latency headers in proxy response page Clarify meaning of latency headers in proxy page and update kong.log PDK latencies field May 28, 2025
@@ -398,6 +398,16 @@ Generates a table with useful information for logging.
The following fields are included in the returned table:
* `client_ip` - client IP address in textual format.
* `latencies` - request/proxy latencies.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are all of these available in 2.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, only 3.11 onwards

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was under the expectation that this page would be sourced from our log.lua PDK source code, but apparently it is not the case. We have to duplicate the docs in both places. Is that correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Issues/ PRs whose changes should not be merged at this time review:copyedit Request for writer review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants