Closed carloseltuerto closed 2 years ago
@carloseltuerto throwing this one over to you - I think we can mark fixed once the cronet tests are passing
It turns out that EnvoyMobile receives exactly the number of expected bytes from the Socket.
I enabled the traces, and this line appears:
[2022-01-05 20:21:30.550][1971874][trace][connection] [external/envoy/source/common/network/raw_buffer_socket.cc:24] [C0] read returns: 86
And this value is the one expected by the CronetUrlRequestTest.
However, the test fails with this value: 210
That was a bug in the Java code - the returned value is indeed 86 :-)
Unfortunately, the values being returned are not timestamps. There is some kind or corruption / bad translation. Examples of values found in a single instance of EnvoyFinalStreamIntel:
dnsStart: 140000050487350
dnsEnd: 4
connectStart: 140190016975808
connectEnd: 140190016975792
requestStart: 3691316927787970592
After some more digging, here are some observations:
cancel
is invoked too soon, the setFinalStreamIntel is not called, leaving envoy_final_streamintel completely uninitialized: the Java layer then gets the above random data. The tripping point is this line of code: sometimes the request_decoder_
is not yet set, and sometimes there is no open stream.responseStartMs
is after the requestEndMs
: example: responseStart [2089292035] should start before requestEnd [2089292030]]
have a PR out to fix the memset. are we sure (say from logs) that we're sending the full request before we get a response? For error responses that's not always true.
When a request concludes, the C++ Cronet Engine invokes a "native" Java method to expose some metrics. To implement this, I guess that adding a bunch of "x-envoy-metric-xyz" in the response header could be considered, as long as there is a response header in all circumstances (onSucceeded, onError, onCancel).
As far as I can tell, previous redirect metrics are discarded (otherwise, for example,
dnsStartMs
anddnsEndMs
would not make sense.)And as a reference, here is the C++ header file: https://source.chromium.org/chromium/chromium/src/+/master:net/base/load_timing_info.h And here is what every metric looks like: