Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
// (c) Copyright 2023 Supertenant Ltd. - all rights reserved.
// See LICENSE file in project root for license terms.
"use strict";const processIdentityProvider=require("../../../pidStore"),getCls=require("@supertenant/core").tracing.getCls,coreChildProcess=require("child_process"),shimmer=require("shimmer"),selfPath=require("./selfPath");let logger;function shimSpawn(original){return function(command,args){return"string"==typeof command&&/[^\w]node$/.test(command)&&args&&Array.isArray(args)&&1<=args.length&&/[^\w]edgemicro[^\w]app\.js$/.test(args[0])&&(selfPath.immediate?(logger.debug(`Detected a child_process.spawn of edgemicro/app, instrumenting it by adding --require ${selfPath.immediate}.`),args.unshift(selfPath.immediate),args.unshift("--require")):logger.warn("Detected a child_process.spawn of 'edgemicro/app', but the path to @supertenant/collector is not available, so this edgemicro instance will not be instrumented.")),original.apply(this,arguments)}}logger=require("../../../logger").getLogger("tracing/child_process",newLogger=>{logger=newLogger}),exports.init=function(){shimmer.wrap(coreChildProcess,"spawn",shimSpawn),shimmer.wrap(coreChildProcess,"fork",shimFork)};const bullMasterProcessMatch=/bull\/lib\/process\/master\.js/;function shimFork(original){return function(){var _args=Array.prototype.slice.call(arguments),modulePath=_args[0],args=_args[1];if("string"==typeof modulePath&&bullMasterProcessMatch.test(modulePath)&&args&&args.execArgv){selfPath.immediate?(logger.debug(`Detected a child_process.fork of Bull, instrumenting it by adding --require ${selfPath.immediate}.`),process.env.INSTANA_AGENT_UUID=processIdentityProvider.getFrom().h,args.execArgv.unshift(selfPath.immediate),args.execArgv.unshift("--require")):logger.warn("Detected a child_process.fork of 'Bull processor', but the path to @supertenant/collector is not available, so this Bull processor instance will not be instrumented.");modulePath=original.apply(this,_args);const originalChildProcessSend=modulePath.send;return modulePath.send=function(message){var cls=getCls();let entrySpan=null;cls&&(entrySpan=cls.getCurrentSpan()),message&&"start"===message.cmd&&message.job&&"object"==typeof message.job&&message.job.opts&&entrySpan&&1===entrySpan.k&&(null==message.job.opts&&(message.job.opts={}),null==message.job.opts.instanaTracingContext&&(message.job.opts.instanaTracingContext={}),message.job.opts.instanaTracingContext.X_SUPERTENANT_T=entrySpan.t,message.job.opts.instanaTracingContext.X_SUPERTENANT_S=entrySpan.s),originalChildProcessSend.apply(this,arguments)},modulePath}return original.apply(this,arguments)}}exports.activate=function(){},exports.deactivate=function(){};