diff --git a/lib/dtrace.js b/lib/dtrace.js index 42d6abe..308c1fe 100644 --- a/lib/dtrace.js +++ b/lib/dtrace.js @@ -1,6 +1,4 @@ -// Copyright 2011 Mark Cavage, Inc. All rights reserved. - -var dtrace = require('dtrace-provider'); +// Copyright 2011 Mark Cavage, Inc. All rights reserved.s @@ -79,14 +77,35 @@ var SERVER_PROBES = { module.exports = function () { if (!SERVER_PROVIDER) { - SERVER_PROVIDER = dtrace.createDTraceProvider('ldapjs'); + try { + var dtrace = require('dtrace-provider'); + SERVER_PROVIDER = dtrace.createDTraceProvider('ldapjs'); - Object.keys(SERVER_PROBES).forEach(function (p) { - var args = SERVER_PROBES[p].splice(0); - args.unshift(p); + Object.keys(SERVER_PROBES).forEach(function (p) { + var args = SERVER_PROBES[p].splice(0); + args.unshift(p); - dtrace.DTraceProvider.prototype.addProbe.apply(SERVER_PROVIDER, args); - }); + dtrace.DTraceProvider.prototype.addProbe.apply(SERVER_PROVIDER, args); + }); + } catch (e) { + SERVER_PROVIDER = { + fire: function () { + }, + enable: function () { + }, + addProbe: function () { + var p = { + fire: function () { + } + }; + return (p); + }, + removeProbe: function () { + }, + disable: function () { + } + }; + } SERVER_PROVIDER.enable(); diff --git a/package.json b/package.json index 1464c9e..dd68bb3 100644 --- a/package.json +++ b/package.json @@ -30,10 +30,12 @@ "asn1": "0.1.11", "assert-plus": "0.1.2", "bunyan": "0.21.1", - "dtrace-provider": "0.2.8", "nopt": "2.1.1", "pooling": "0.4.5" }, + "optionalDependencies": { + "dtrace-provider": "0.2.8" + }, "devDependencies": { "tap": "0.4.1", "node-uuid": "1.4.0"