-
-
Save kovetskiy/af7d69475626ab5cb0a6282970c45e57 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var apm = require('elastic-apm-node').start() | |
var http = require('http') | |
var process = require('process') | |
function sleep(time) { | |
var stop = new Date().getTime(); | |
while(new Date().getTime() < stop + time) { | |
; | |
} | |
} | |
function serve(op) { | |
if (op == "error") { | |
throw new Error("oops, a test error!") | |
} | |
console.log("sleep", op) | |
sleep(parseInt(op)) | |
} | |
http.createServer(function (req, res) { | |
apm.setTransactionName(req.method +' ' + req.url) | |
op = req.url.substr(1) | |
console.log(op) | |
try { | |
serve(op) | |
} catch (err) { | |
apm.captureError(err) | |
} | |
res.end() | |
}).listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment