chrisa / node-dtrace-provider

Native DTrace probes for node.js apps
Other
319 stars 70 forks source link

If the platform looks like it should have DTrace available, log a failure to load the bindings. #106

Open zhy1 opened 6 years ago

zhy1 commented 6 years ago

var os, fs, dtrace;
if (runtimeEnv === 'browser') {
    os = {
        hostname: function () {
            return window.location.host;
        }
    };
    fs = {};
    dtrace = null;
} else {
    os = require('os');
    fs = require('fs');
    try {
        dtrace = require('dtrace-provider' + '');
    } catch (e) {
        dtrace = null;
    }
}
If the platform looks like it  should  have DTrace  available, log a failure to load the bindings.

```
![image](https://user-images.githubusercontent.com/14029393/32403335-39efc426-c105-11e7-93e9-4489f191f4a8.png)