ErrorStack – Graphite – StatsD – NodeJS – Cron Success Story

At work I am implementing ErrorStack, Graphite, and StatsD into our projects and tools. We are doing this so we can better understand how our users interact with our products and so we can respond faster and more efficiently to errors.

  • ErrorStack helps us collect, report, and notify us of errors across all of our applications no matter where they are.
  • Graphite stores and graphes analytical data provided by our products.
  • StatsD run by NodeJS collects our analytical data via UDP so there is minimal impact on the performance of our applications as we collect the data.
  • Cron helps us run various tasks on our servers and helps us ensure that things are running smoothly
I recently setup a Cron script to ensure that Node is running. If the script finds that Node is no longer running, it reports the issue to ErrorStack and then kicks off the process again. This ensures that we will be able to collect data via StatsD with minimalĀ interruptions. Because I keep a browser window open to keep an eye on some key stats in graphite, I noticed a sudden drop in total metrics received and written to disk.

Just a minute or two later I got an email alert from ErrorStack notifying me that Node had died. After checking the graphite graph again I saw that the total metrics received had gone back up because the Cron script was able to restart the process. I love it when a plan comes together like that.

#!/bin/bash
PID=`pidof node`
if [ $PID > 0 ]; then
  echo "node still running"
else
  echo "node died"
  curl -d "Msg=node died&_s=yourErrorStackKeyGoesHere&_r=json" http://www.errorstack.com/submit
  # command to start node server again goes here
fi

Here is some of the code that I use to report errors to ErrorStack https://github.com/MikeGrace/ErrorStack-Reporting-Tools

Delete Data From Graphite

If you have set up a Graphite server and played with it like I have, you have some data in there cluttering up your interface.

graphite resource tree

You can get rid of any of the data or folders by deleting them from the server. The data is stored in files found starting at

/opt/graphite/storage/whisper/

Happy deleting!

Cross Browser Testing For All Versions Of IE (Internet Explorer)

IE 1.5

Ever had the urge to test your site or your client’s site on all versions of IE? Me either! Introducing IE Collection. You can download the .exe that will install all the versions of IE that are compatible with your version of windows all the way back to IE 1! So whether your are feeling nostalgic or just need to get some testing done, download it from FileForum or Softpedia

To celebrate this blog post on this year’s Programmer’s Day, here is a this blog post as seen through IE 2′s eyes. How meta ; )
blog post rendered in IE 2

Java Global Exception Handling

It’s been a while since I have worked with Java and it’s time for me to brush up so I have decided to do 30 days of Java. I will be attempting to learn something new or explain something about Java each day.

In many of my projects I use a remote error collecting service called ErrorStack. Love it! My apps throw errors over the internet to it and it generates report and has a myriad of ways to alert me. I do my best to write code that doesn’t have errors and handles errors and exception gracefully but it still happens. This is where the Java 1.5 setDefaultUncaughtExceptionHandler comes in to play.

I wrote some quick code to test out the feature

package org.michaelgrace.sandbox;
 
public class GlobalErrorHandling {
 
  public static void main(String[] args) {
    Handler handler = new Handler();
    Thread.setDefaultUncaughtExceptionHandler(handler);
 
    throw new RuntimeException("party on error!");
  }
}
 
class Handler implements Thread.UncaughtExceptionHandler {
  public void uncaughtException(Thread t, Throwable e) {
    System.out.println("Where did that error come from?!");
    System.out.println("This is where I would report the error to ErrorStack");
    System.out.println(e.getMessage());
    System.out.println(t.toString());
  }
}

I exported the class to a jar using Eclipse and ran it from the command line

mgrace$ java -jar global-error-test.jar 
Where did that error come from?!
This is where I would report the error to ErrorStack
party on error!
Thread[main,5,main]

It worked!

I plan on building a class for making it easy to report errors to ErrorStack and will release it to the world when I do.

Resources: http://www.nomachetejuggling.com/2006/06/13/java-5-global-exception-handling/