Here’s a real example of using the ChromeTrace library to take a look at what a triggered task is up to, and examine what we can see in the tracing tool. I’m going to add some tracing to Update analytics batch code and the 6 minute limit

Here’s the code for one of the triggered functions before I add tracing

  • Create a trace object, We will make it global so I can use it inside functions later

  • Add a trace round the whole thing

  • I can report errors to the tracing utility, so we’ll catch them. Then first step is to time the setup stage

  • time how long to get all the pages on the site

  • time how long to get all the plus ones, then finish with a success

  • and we’ll catch any error and report that too

  • Close off the overall timer, and dump the results to a drive file

Here is the whole code together

What we get when inspected in Chrome

Let’s dig into the addPlusOnes function – this is recursive so it should be interesting to see how that works

Injecting some tracing gives this.

We can see a nice pattern of a site pages and its children, because of this

and tracing allows you to zoom in

Click on some bar to get some details

Note also that we had a counter going

The light gray histogram at the top shows the counters

And we can click at any point in time to look at the counter

Logging errors

Let’s simulate an error and see what we get – it failed at the pink bar
What’s interesting is that we have exactly the error logged
for help and more information, join our community, follow the blog and or follow me on Twitter. If you have any additional Chrome tracing types activated, pls let me know.