You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "wu-sheng (via GitHub)" <gi...@apache.org> on 2026/10/17 12:01:29 UTC
[PR] Sync the Envoy access log proto and drop retried requests' internal request latency [skywalking]
wu-sheng opened a new pull request, #14148:
URL: https://github.com/apache/skywalking/pull/14148
### Fix the Envoy ALS sidecar internal request latency counting earlier attempts of a retried request
- [x] Add a unit test to verify that the fix works.
- [x] Explain briefly why the bug exists and how to fix it.
Follow-up to #14147.
**Why the bug exists.** Envoy's gRPC ALS measures every `time_to_*` field from the start of the downstream request (`source/common/stream_info/utility.cc`, `duration()`), and each retry attempt installs fresh upstream info on the logged StreamInfo (`source/common/router/upstream_request.cc`). So for a request Envoy retried or hedged, `time_to_first_upstream_tx_byte`, which OAP reads as the sidecar internal request latency, is the time from the request start to the logged attempt's first upstream byte. It includes the earlier attempts' wait on the upstream and the backoff. It is not a sum of per-attempt sidecar times, so dividing by the attempt count does not recover a per-attempt value. The TCP proxy counts its connect attempts the same way (`source/common/tcp_proxy/tcp_proxy.cc`, `setAttemptCount`), which matters for HTTP CONNECT tunneling, where upstream timings reach the TCP access log.
**How it is fixed.**
- Sync `envoy/data/accesslog/v3/accesslog.proto` with Envoy **v1.40.0** (byte-identical copy). The vendored copy dated from #8434 (2022-01) and had no `upstream_request_attempt_count`. The change is additive only: no field was removed or renumbered. Also add `envoy/annotations/deprecation.proto`, which the new file imports.
- In `LogEntry2MetricsAdapter` (HTTP) and `TCPLogEntry2MetricsAdapter` (TCP), report a `0` internal request latency when `upstream_request_attempt_count > 1`. An older Envoy that doesn't send the field reads `0` and keeps today's behaviour. The internal response latency is unchanged: it subtracts two times taken from the same logged attempt, so the start reference cancels out.
- Add the Envoy project's NOTICE ("Copyright The Envoy Project Authors") to `NOTICE` and `dist-material/release-docs/NOTICE`. It had been missing since the Envoy protos were first vendored.
Tests: `testHTTPInternalLatencyWithOneAttempt`, `testHTTPInternalRequestLatencyAfterRetry`, and `testTCPInternalRequestLatencyAfterRetriedConnect`. Without the guard, the two retry tests fail with `expected: <0> but was: <3029000000>`.
Known limits, left as follow-ups:
- `0` still counts in `longAvg()`.
- A stale upstream response time can still be logged when a global timeout fires during a retry backoff.
- `access_log_type` could be used to skip non-final entries (periodic logs, tunnel-established logs).
- [ ] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<issue number>.
- [x] Update the [`CHANGES` log](https://github.com/apache/skywalking/blob/master/docs/en/changes/changes.md).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_014fUcS4wLBpmbuNHDvuvd9f
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sync the Envoy access log proto and leave unmeasurable sidecar internal latencies out [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #14148:
URL: https://github.com/apache/skywalking/pull/14148#discussion_r4303057733
##########
oap-server/server-starter/src/main/resources/oal/mesh.oal:
##########
@@ -16,21 +16,22 @@
*
*/
-service_sidecar_internal_req_latency_nanos = from(Service.sideCar.internalRequestLatencyNanos).longAvg();
-service_sidecar_internal_resp_latency_nanos = from(Service.sideCar.internalResponseLatencyNanos).longAvg();
+// A negative internal latency is one the access log could not measure, see LogEntry2MetricsAdapter#UNKNOWN_INTERNAL_LATENCY.
+service_sidecar_internal_req_latency_nanos = from(Service.sideCar.internalRequestLatencyNanos).filter(sideCar.internalRequestLatencyNanos >= 0).longAvg();
+service_sidecar_internal_resp_latency_nanos = from(Service.sideCar.internalResponseLatencyNanos).filter(sideCar.internalResponseLatencyNanos >= 0).longAvg();
Review Comment:
@kezhenxu94 @wankai123 I accidently noticed this issues. The newer Envoy has a chance to enhnace. But can't fix this in old Envoy/Istio.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sync the Envoy access log proto and leave unmeasurable sidecar internal latencies out [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng merged PR #14148:
URL: https://github.com/apache/skywalking/pull/14148
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Sync the Envoy access log proto and leave unmeasurable sidecar internal latencies out [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #14148:
URL: https://github.com/apache/skywalking/pull/14148#discussion_r4303067541
##########
oap-server/server-starter/src/main/resources/oal/mesh.oal:
##########
@@ -16,21 +16,22 @@
*
*/
-service_sidecar_internal_req_latency_nanos = from(Service.sideCar.internalRequestLatencyNanos).longAvg();
-service_sidecar_internal_resp_latency_nanos = from(Service.sideCar.internalResponseLatencyNanos).longAvg();
+// A negative internal latency is one the access log could not measure, see LogEntry2MetricsAdapter#UNKNOWN_INTERNAL_LATENCY.
+service_sidecar_internal_req_latency_nanos = from(Service.sideCar.internalRequestLatencyNanos).filter(sideCar.internalRequestLatencyNanos >= 0).longAvg();
+service_sidecar_internal_resp_latency_nanos = from(Service.sideCar.internalResponseLatencyNanos).filter(sideCar.internalResponseLatencyNanos >= 0).longAvg();
Review Comment:
Which Istio versions are enhanced, read from the Envoy commit each `istio/proxy` release branch pins (`ENVOY_SHA`) and from Envoy's own source:
| Part of this PR | What it needs from Envoy | Istio versions enhanced |
|---|---|---|
| A missing timing, or nothing sent upstream, is left out instead of counted as `0` | nothing new | all |
| The internal request latency of a retried or hedged request is left out | `upstream_request_attempt_count`, sent by the gRPC ALS since Envoy 1.24 | **Istio 1.16+**: 1.16 ships Envoy 1.24; 1.15 ships Envoy 1.23, which doesn't send it |
| Envoy's own replies, such as the 504 of a timeout during a retry backoff, are left out of the internal response latency | `response_code_details`, sent since Envoy 1.12 or earlier | everything that sends the attempt count, and older |
On an older Envoy the field is just absent. OAP reads `0` / `""` and keeps the previous behaviour, so nothing breaks; the retry and backoff cases aren't detected there.
Our e2e matrix covers Istio 1.21–1.29 (Envoy 1.29–1.37), so every tested version is enhanced. Istio 1.30 and 1.31 (Envoy 1.38 and 1.39) aren't in the matrix, but they send both fields too. The proto is synced to Envoy v1.40.0 only as a file version; nothing in this PR needs Envoy 1.40.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org