Chrome Distributed Trace Issue

I'd like to refer to a previous issue I raised in Distributed Trace doesn't seem to work in Chrome above version 71.x

The problem as defined in that thread is that Chrome doesn't seem to allow distributed traces to propagate into backends from at least version 72+. Testing on version 71 shows that the distributed trace is working.

I cannot find any references on the web pertaining to this. The closest is about Chrome implementing CORB for their Content Extension Scripts (https://www.chromium.org/Home/chromium-security/extension-content-script-fetches)

Our worry is that we've made a bit of distributed trace instrumentation work in the past that we are afraid would no longer work in newer Chrome versions when we go live in a few weeks. We are still on development and have not tested this scenario on all our apps but the POC in the above thread seems to paint a bleak picture.

We are wondering if you have any information on this.

Reference screenshots below:

Chrome 74.0.3729.157

Chrome 71.0.3578.10

Note that in Chrome 71 a POST with 202 status was attained.

Thanks!

Hi @digitalron,

Thanks for reporting the issue.

I haven't been able to reproduce this issue locally.
Would it be possible for you to provide a reproduction online?

Cheers,
Hamid

Hi Hamid,

I'll try to put up a complete replica online and get back to you once it's set up.

Regards,

Ronald

@Hamidreza, I've set up a similar stack in Linode and I will provide you access to it to see what is happening and even to see config settings. I'll provide access via PM. Please let me know if you need anything else.

Many thanks!

@digitalron,

Thanks for the reproduction.
I have now investigated the application and it seems that the transaction is discarded because it doesn't have any spans. The reason for this is that the transaction is ended before the XHR span is finished. In the following code the transaction is ended the first time the state changes which is not the time the request has finished (and therefore the XHR span ends)

                http.onreadystatechange = function() {//Call a function when the state changes.
                    if(http.readyState == 4 && http.status == 200) {
                        resp = http.response;
                        document.getElementById("txtItemColorDescribed").value = resp
                    }

                    transaction.end();
                }
                http.send(null);

A solution to this would be:

                http.onreadystatechange = function() {//Call a function when the state changes.
                    if(http.readyState == 4 && http.status == 200) {
                        resp = http.response;
                        document.getElementById("txtItemColorDescribed").value = resp
                        setTimeout(function(){transaction.end();}) // setTimeout is used because we can not be sure of the order of execution of event listeners
                    }
                }
                http.send(null);

@Hamidreza ,

Greatly appreciate your efforts for looking into this.

I applied the recommended code change and it does work on Chrome now, and has remained working with Firefox and Safari.

I was just curious though why with the original code, it worked fine with Chrome 71 and earlier, and only stopped from Chrome 72. Any ideas?

Anyway, I will have teams adopt this pattern.

Many thanks and cheers!

Ronald

It seems that this is a race condition and some changes in Chrome 72 might make this race condition more likely to happen.

By the way, I have opened this issue to provide helpful logs in case we discard a transaction .

Thanks Hamid, and that issue opened would be a useful tool for us as well in debugging similar problems. Cheers!

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.