Skip to content

Instantly share code, notes, and snippets.

@camshaft
Created February 7, 2013 02:53
Show Gist options
  • Save camshaft/4728018 to your computer and use it in GitHub Desktop.
Save camshaft/4728018 to your computer and use it in GitHub Desktop.
Node/Riemann Example
RIEMANN_HOST=localhost
RIEMANN_PORT=5555
/**
* Module dependencies
*/
var express = require("express")
, responseTime = require("riemann-response-time")
, errorHandler = require("riemann-error-handler");
/**
* Expose app
*/
var app = module.exports = express();
app.configure(function() {
app.set("host", "test.localhost");
app.use(responseTime({
host: app.get("host"),
service: "riemann-node-response-time-tests",
description: "This is a test",
tags: ["tests"]
}));
app.use(app.router);
app.use(errorHandler({
host: app.get("host"),
service: "riemann-node-error-handler-tests",
tags: ["tests"]
}));
app.use(express.errorHandler());
});
app.get("/", function(req, res, next) {
setTimeout(function() {
res.send("Hello!");
}, Math.floor(Math.random()*process.env.VARIANCE || 5))
});
app.get("/error", function(req, res, next) {
console.log("Error");
next(new Error("Error from "+req.ip));
});
{
"name": "test-app",
"version": "0.0.0",
"description": "Riemann test app",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "",
"author": "Cameron Bytheway <[email protected]>",
"license": "MIT",
"dependencies": {
"riemann-response-time": "0.1.0",
"riemann-error-handler": "0.1.0",
"express": "~3.1.0",
"riemann": "~0.4.0",
"startup": "~0.1.6"
},
"engines": {
"node" : "0.8.x",
"npm" : "1.1.x"
}
}
web: ./node_modules/.bin/startup start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment