Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.serializers = objCopy(parent.serializers);
this.src = parent.src;
this.fields = objCopy(parent.fields);
if (options.level) {
this.level(options.level);
}
} else {
this._level = Number.POSITIVE_INFINITY;
this.streams = [];
this.serializers = null;
this.src = false;
this.fields = {};
}
if (!dtp && dtrace) {
dtp = dtrace.createDTraceProvider('bunyan');
for (var level in levelFromName) {
var probe;
probes[levelFromName[level]] = probe =
dtp.addProbe('log-' + level, 'char *');
// Explicitly add a reference to dtp to prevent it from being GC'd
probe.dtp = dtp;
}
dtp.enable();
}
// Helpers
function addStream(s) {
'use strict'
var net = require('net')
var fork = require('child_process').fork
var impromptu = require('../lib/impromptu')
var path = require('path')
var fs = require('fs')
var minimist = require('minimist')
var dtp = require('dtrace-provider').createDTraceProvider('impromptu')
dtp.addProbe('socket-connect', 'int')
dtp.addProbe('socket-end', 'int')
dtp.enable()
var argv = minimist(process.argv.slice(2), {
defaults: {
logfile: true,
foreground: false
},
alias: {
h: 'help',
v: 'version'
}
})
// If you use a Unix Domain Socket, its filename must be unique.
function createDTraceProbes(name) {
assert.string(name, 'name');
if (DTPS[name]) {
return (DTPS[name]);
}
var dtp = dtrace.createDTraceProvider(name);
var probes = {
// these are all object_id, state
release: dtp.addProbe('release', 'int', 'json'),
remove: dtp.addProbe('remove', 'int', 'json'),
kill: dtp.addProbe('kill', 'int', 'json'),
create: dtp.addProbe('create', 'int', 'json'),
// additionally create_time of object
acquire: dtp.addProbe('acquire', 'int', 'json', 'char *'),
// additionally "ok"
assert: dtp.addProbe('assert', 'int', 'json', 'int'),
// just num_items to check and state
check: dtp.addProbe('check', 'int', 'json'),
function createDTrace(name) {
// see https://github.com/mcavage/node-restify/issues/80 and
// https://github.com/mcavage/node-restify/issues/100
if (!DTRACE) {
try {
var d = require('dtrace-provider');
DTRACE = d.createDTraceProvider(name);
} catch (e) {
DTRACE = {
addProbe: function addProbe() {
var p = {
fire: function () {}
};
return (p);
},
enable: function enable() {},
fire: function fire() {},
removeProbe: function () {},
disable: function () {}
};
}
}
value: function start(cfg, err) {
var _this15 = this;
var config = undefined,
headers = undefined,
pages = undefined;
config = clone(defaultConfig);
// Merging custom with default config
merge(config, cfg || {});
this.dtp = dtrace.createDTraceProvider(config.id || "turtle-io");
// Duplicating headers for re-decoration
headers = clone(config.headers);
// Overriding default error handler
if (typeof err === "function") {
this.error = err;
}
// Setting configuration
if (!config.port) {
config.port = 8000;
}
merge(this.config, config);
function dtrace() {
var dtp;
try {
var d = require('dtrace-provider');
dtp = d.createDTraceProvider('restifyUnitTest');
} catch (e) {
dtp = null;
}
return (dtp);
}
/**
*
* This node app is used to test firing a probe while running dtrace vs no running dtrace
* It will loop n times and fire a probe. You time the test tracing with dtrace and testing without tracing.
* When executing the app it will sleep 10s giving you a chance to start tracing with dtrace.
*
* Author: Michael Zeller
* Date: 4/23/12
*/
//number of times to loop
var n = 1000000
//setup dtrace probe
var dtp = require('dtrace-provider').createDTraceProvider('looper-test');
dtp.addProbe('looper-start', 'char *');
dtp.enable();
//function that will loop n times firing a dtrace probe.
function looper(text) {
for ( var i = 0; i < n; i ++ ) {
dtp.fire('looper-start', function () { return [text] });
};
}
setTimeout(looper, 10000, "test looper");
module.exports = function exportStaticProvider() {
if (!PROVIDER) {
PROVIDER = dtrace.createDTraceProvider('moray');
PROVIDER._fast_probes = {};
Object.keys(PROBES).forEach(function (p) {
var args = PROBES[p].splice(0);
args.unshift(p);
var probe = PROVIDER.addProbe.apply(PROVIDER, args);
PROVIDER._fast_probes[p] = probe;
});
PROVIDER.enable();
}
return (PROVIDER);
}();
module.exports = (function exportStaticProvider() {
if (!PROVIDER) {
try {
var dtrace = require('dtrace-provider');
PROVIDER = dtrace.createDTraceProvider('resource-machine');
} catch (e) {
PROVIDER = {
fire: function () {},
enable: function () {},
addProbe: function () {
var p = {
fire: function () {}
};
return (p);
},
removeProbe: function () {},
disable: function () {}
};
}
}
var result = false;
try {
result = !!require.resolve('dtrace-provider');
}
catch (err) {}
internals.DTrace.isInstalled = function () {
return result;
};
return result;
};
internals.DTrace.Provider = internals.DTrace.isInstalled() && require('dtrace-provider').DTraceProvider;