Skip to content

Instantly share code, notes, and snippets.

@falsecz
Created May 7, 2014 09:09
Show Gist options
  • Save falsecz/3eecfc5f9b8a0a79fcb2 to your computer and use it in GitHub Desktop.
Save falsecz/3eecfc5f9b8a0a79fcb2 to your computer and use it in GitHub Desktop.
Wrap request for zipkin tracing
22 start { uri: 'http://false.cz' }
33 start { uri: 'http://false.cz/notfound' }
22 end 200 { date: 'Wed, 07 May 2014 09:09:40 GMT',
server: 'Apache/2.4.7 (Debian) SVN/1.8.5 mod_fcgid/2.3.9 mod_jk/1.2.37 PHP/5.5.8-2 OpenSSL/1.0.1g mod_perl/2.0.8 Perl/v5.18.2',
'x-powered-by': 'PHP/5.5.8-2',
vary: 'Accept-Encoding',
'content-length': '869',
'keep-alive': 'timeout=5, max=100',
connection: 'Keep-Alive',
'content-type': 'text/html' }
done 22
33 end 404 { date: 'Wed, 07 May 2014 09:09:40 GMT',
server: 'Apache/2.4.7 (Debian) SVN/1.8.5 mod_fcgid/2.3.9 mod_jk/1.2.37 PHP/5.5.8-2 OpenSSL/1.0.1g mod_perl/2.0.8 Perl/v5.18.2',
'content-length': '206',
'keep-alive': 'timeout=5, max=100',
connection: 'Keep-Alive',
'content-type': 'text/html; charset=iso-8859-1' }
done 33
request = require 'request'
rr = (traceId) ->
o = request.defaults {}, (opts, callback) ->
console.log traceId, "start", opts
request.call request, opts, (err, res, body) ->
console.log traceId, "end", res.statusCode, res.headers
callback err, res, body
o
rr('22').get 'http://false.cz', (err, r, body) ->
console.log 'done 22'
rr('33').get 'http://false.cz/notfound', (err, r, body) ->
console.log 'done 33'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment