Permalink
Browse files

DTrace 0.2.0 (more arguments)

  • Loading branch information...
1 parent 9baa33a commit 807b9b9d6ca62de87392c4d12aae7ea38eb4c963 Mark Cavage committed Aug 31, 2012
Showing with 81 additions and 50 deletions.
  1. +1 −1 deps/javascriptlint
  2. +62 −41 lib/dtrace.js
  3. +1 −1 lib/index.js
  4. +5 −0 lib/request.js
  5. +7 −2 lib/server.js
  6. +4 −4 package.json
  7. +1 −1 tools/mk/Makefile.deps
View
@@ -12,52 +12,73 @@ function addProbes(dtrace, name) {
var obj = {};
// id, requestid, user, user-agent, content-type, content-length
- dtrace.addProbe(name + '-start',
- 'int',
- 'char *',
- 'char *',
- 'char *',
- 'char *',
- 'int');
-
- // id, requestid, statusCode, content-type, content-length
- dtrace.addProbe(name + '-done',
- 'int',
- 'char *',
- 'int',
- 'char *',
- 'int',
- 'int');
+ // md5, accept, url, path, isKeepAlive, version, isSecure, isChunked
+ var pStart = dtrace.addProbe(name + '-start',
+ 'int',
+ 'char *',
+ 'char *',
+ 'char *',
+ 'char *',
+ 'int',
+ 'char *',
+ 'char *',
+ 'char *',
+ 'char *',
+ 'char *',
+ 'int',
+ 'char *',
+ 'int');
+
+ // id, requestid, statusCode, content-type, content-length,
+ // content-md5, version
+ var pDone = dtrace.addProbe(name + '-done',
+ 'int',
+ 'char *',
+ 'int',
+ 'char *',
+ 'int',
+ 'int',
+ 'char *',
+ 'char *');
obj.start = function fireProbeStart(req) {
- dtrace.fire(name + '-start',
- function probeStart() {
- var details = [
- req.connection.fd,
- req.id,
- (req.username || null),
- (req.userAgent || null),
- req.contentType,
- (req.contentLength || 0)
- ];
-
- return (details);
- });
+ pStart.fire(function probeStart() {
+ var details = [
+ req.connection.fd,
+ req.id(),
+ (req.username || null),
+ (req.userAgent() || null),
+ (req.contentType() || null),
+ (req.contentLength() || 0),
+ (req.contentType() || null),
+ req.header('content-md5', null),
+ req.header('accept', null),
+ req.href(),
+ req.path(),
+ (req.isKeepAlive() ? 1 : 0),
+ req.version(),
+ (req.isSecure() ? 1 : 0),
+ (req.isChunked() ? 1 : 0)
+ ];
+
+ return (details);
+ });
};
obj.done = function fireProbeDone(req, res) {
- dtrace.fire(name + '-done',
- function probeDone() {
- var details = [
- req.connection.fd,
- req.id,
- res.code,
- (res.contentType || null),
- (res.contentLength || 0)
- ];
-
- return (details);
- });
+ pDone.fire(function probeDone() {
+ var details = [
+ req.connection.fd,
+ req.id(),
+ res.statusCode || 200,
+ (res.get('content-type') || null),
+ (res.get('content-length') || 0),
+ (res.get('content-md5') || 0),
+ (res.get('api-version') || null)
+ ];
+
+ return (details);
+ });
};
return (obj);
View
@@ -117,6 +117,7 @@ module.exports = {
var opts = clone(options || {});
var server;
+ opts.name = opts.name || 'restify';
if (opts.dtrace) {
// We shouldn't call enable on the DTrace provider if
// the user passed it in.
@@ -128,7 +129,6 @@ module.exports = {
// clone can't clone something with prototypes so we need to
// manually set opts.log and opts.router to the right objects:
- opts.name = opts.name || 'restify';
opts.log = opts.log ? options.log : createLogger(opts.name);
opts.router = opts.router ? options.router : createRouter(opts);
View
@@ -295,3 +295,8 @@ Request.prototype.toString = function toString() {
return (str);
};
+
+
+Request.prototype.userAgent = function userAgent() {
+ return (this.headers['user-agent']);
+};
View
@@ -219,8 +219,13 @@ Server.prototype.listen = function listen() {
args.push(save);
args.push(function restifyListenCallback() {
- if (!self._user_dtrace)
- self.dtp.enable();
+ if (!self._user_dtrace) {
+ try {
+ self.dtp.enable();
+ } catch (e) {
+ self.log.error(e, 'Failed to enable DTrace');
+ }
+ }
self._listening = true;
if (typeof (save) === 'function')
View
@@ -35,13 +35,13 @@
},
"dependencies": {
"assert-plus": "0.1.0",
- "bunyan": "0.10.0",
+ "bunyan": "0.13.5",
"clone": "0.1.0",
"byline": "2.0.2",
"formidable": "1.0.11",
"http-signature": "0.9.9",
"lru-cache": "1.1.0",
- "mime": "1.2.6",
+ "mime": "1.2.7",
"node-uuid": "1.3.3",
"pooling": "0.2.2",
"qs": "0.5.0",
@@ -51,11 +51,11 @@
},
"devDependencies": {
"cover": "0.2.8",
- "filed": "0.0.6",
+ "filed": "0.0.7",
"nodeunit": "0.7.4"
},
"optionalDependencies": {
- "dtrace-provider": "0.0.9"
+ "dtrace-provider": "0.2.0"
},
"scripts": {
"test": "./node_modules/.bin/nodeunit ./test/*.test.js"
View
@@ -18,7 +18,7 @@
# javascriptlint
#
JSL_EXEC ?= deps/javascriptlint/build/install/jsl
-JSL ?= python $(JSL_EXEC)
+JSL ?= $(JSL_EXEC)
$(JSL_EXEC): | deps/javascriptlint/.git
cd deps/javascriptlint && make install

0 comments on commit 807b9b9

Please sign in to comment.