forked from chrisa/node-dtrace-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtrace-provider.js
40 lines (35 loc) · 1.17 KB
/
dtrace-provider.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var DTraceProvider;
function DTraceProviderStub() {}
DTraceProviderStub.prototype.addProbe = function(name) {
var p = { 'fire': function () {} };
this[name] = p;
return (p);
};
DTraceProviderStub.prototype.enable = function() {};
DTraceProviderStub.prototype.fire = function() {};
DTraceProviderStub.prototype.disable = function() {};
var builds = ['Release', 'default', 'Debug'];
for (var i in builds) {
try {
var binding = require('./build/' + builds[i] + '/DTraceProviderBindings');
DTraceProvider = binding.DTraceProvider;
break;
} catch (e) {
// if the platform looks like it _should_ have DTrace
// available, log a failure to load the bindings.
if (process.platform == 'darwin' ||
process.platform == 'solaris' ||
process.platform == 'freebsd') {
console.error(e);
}
}
}
if (!DTraceProvider) {
DTraceProvider = DTraceProviderStub;
}
exports.DTraceProvider = DTraceProvider;
exports.createDTraceProvider = function(name, module) {
if (arguments.length == 2)
return (new exports.DTraceProvider(name, module));
return (new exports.DTraceProvider(name));
};