Skip to content
This repository has been archived by the owner on Jul 31, 2019. It is now read-only.

Bug 862008 - Add statsd metrics to Thimble Express app #32

Merged
merged 1 commit into from
May 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ You can then run Thimble from the thimble.webmaker.org directory using
Environment variables
---------------------

there is a special file that is used for environment variables in lieu of
There is a special file that is used for environment variables in lieu of
actually setting these for development purposes. The base file is
```env.dist``` and is self documented. Simply run through it and set your
values accordingly. To use these values during development, copy this
Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var ajax = require('request'),
fs = require('fs'),
habitat = require('habitat'),
makeAPI = require('./lib/makeapi'),
middleware = require( "./lib/middleware"),
mysql = require('mysql'),
nunjucks = require('nunjucks'),
path = require('path'),
Expand All @@ -19,6 +18,7 @@ habitat.load();

var app = express(),
env = new habitat(),
middleware = require( "./lib/middleware")(env),
make = makeAPI(env.get("MAKE")),
nunjucksEnv = new nunjucks.Environment(new nunjucks.FileSystemLoader('views'));

Expand Down
14 changes: 11 additions & 3 deletions env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export BLEACH_ENDPOINT="http://localhost:5000"
# secret used to sign cookie. any long string will do
export SECRET="irrelephant"

# dev or deploy
# development or production
export NODE_ENV="development"

# database settings
Expand All @@ -42,5 +42,13 @@ export S3_SECRET="irrelephant"

# Optional google analytics settings - if used, they will inject
# the google analytics JS snippet with your information filled in.
GA_ACCOUNT=
GA_DOMAIN=
export GA_ACCOUNT=
export GA_DOMAIN=

# statsd metrics collection. If the following are left empty, no stats
# will be collected or sent to a server. Only STATSD_HOST and STATSD_PORT
# are required. STATSD_PREFIX is an optional prefix for all stats (defaults
# to "development.thimble" or "production.thimble" if left blank).
export STATSD_HOST=
export STATSD_PORT=
export STATSD_PREFIX=
11 changes: 11 additions & 0 deletions lib/metrics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = function(env) {
var options = {
host: env.get('STATSD_HOST'),
port: env.get('STATSD_PORT'),
prefix: env.get('STATSD_PREFIX') || env.get('NODE_ENV') + ".thimble",
// If we don't have a host configured, use a mock object (no stats sent).
mock: !env.get('STATSD_HOST')
},
statsd = new (require('node-statsd').StatsD)(options);
return statsd;
};
Loading