Created
April 13, 2015 15:49
-
-
Save megastef/3153fc8a23a2ef10e394 to your computer and use it in GitHub Desktop.
How to monitor restify with SPM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to monitor Restify API's using SPM for Node.js | |
// https://www.npmjs.com/package/spm-agent-nodejs | |
// http://blog.sematext.com/2015/03/30/nodejs-iojs-monitoring/ | |
// note: set env variable: "SPM_TOKEN=YOURTOKEN" | |
var spmAgent = require('spm-agent-nodejs') // that's all, when process.env.SPM_TOKEN is already set. | |
var restify = require('restify') | |
var server = restify.createServer({ | |
name: 'myapp', | |
version: '1.0.0' | |
}) | |
server.use(restify.acceptParser(server.acceptable)) | |
server.use(restify.queryParser()) | |
server.use(restify.bodyParser()) | |
server.get('/echo/:name', function (req, res, next) { | |
res.send(req.params) | |
return next() | |
}) | |
server.listen(8080, function () { | |
console.log('%s listening at %s', server.name, server.url) | |
}) |
Author
megastef
commented
Apr 13, 2015
- spm-agent-nodejs - npm package
- Blog about Node.js / io.js monitoring in SPM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment