A Funny Health Graph

Health graphs always amuse me. I occasionally have to scratch my head and wonder what exactly is being measured.

Take the graph below. At first, the service has zero users and a zero error rate. But once it gets to 1 user (July 19), the error rate ramps right up to 100% and stays at 100% error rate even when there are no users using it (July 20 – 21 part of the graph).

How can there be an error rate if it’s not being used?

Just another day in amusing metrics.

Extract And Process XML Using Apps Script

Here’s a short code snippet demonstrating how to retrieve and parse a XML file using Apps Script. First, here’s how to download and parse the file:

var url = "URL to XML";
var xml = UrlFetchApp.fetch(url).getContentText();
var xml_document = XmlService.parse(xml);
var xml_root = xml_document.getRootElement();

Once the file is downloaded, you can retrieve child elements by calling getChild/getChildren. GetChild returns the first instance of the named element, and getChildren returns an array listing every element instance:

var xml_items = xml_root.getChild("channel").getChildren("item");

And finally, here’s how to retrieve the text content of an element:

var title = new String(xml_item.getChild("title").getContent(0));