This is a demo app showing how to use Instrumental in an Express app. Below you'll see some basic directions and then the original Express Demo README. Feel free to browse the changes we've made to see just how easy it is.
Add the Instrumental Agent to package.json
.
{
"dependencies": {
"instrumental-node": "^1.x"
},
}
Run the installation:
npm install
Add the Instrumental Agent and configuration to your app:
var I = require('instrumental-node');
I.configure({
// from here: https://instrumentalapp.com/docs/tokens
apiKey: process.env.INSTRUMENTAL_API_KEY, // 'project_api_token',
// optional, default shown
host: 'collector.instrumentalapp.com',
// optional, default shown
enabled: true,
});
You can use the enabled
to enable or disable the agent in different environments.
Now add instrumentation to your app wherever you'd like more info. For instance, if your users can create blog posts, perhaps you'll instrument blog post creation like so:
I.increment("blog_post.create");
A barebones Node.js app using Express 4.
Make sure you have Node.js and the Heroku Toolbelt installed.
git clone git@github.com:heroku/node-js-sample.git # or clone your own fork
cd node-js-sample
npm install
npm start
Your app should now be running on localhost:5000.
heroku create
git push heroku master
heroku open
Alternatively, you can deploy your own copy of the app using the web-based flow:
For more information about using Node.js on Heroku, see these Dev Center articles: