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";let isMainThread=!0;try{isMainThread=require("worker_threads").isMainThread}catch(err){}const tracing=require("@supertenant/core")["tracing"],agentConnection=require("../agentConnection"),agentOpts=require("../agent/opts"),initializedTooLate=require("../util/initializedTooLate"),metrics=require("../metrics"),pidStore=require("../pidStore"),requestHandler=require("../agent/requestHandler"),transmissionCycle=require("../metrics/transmissionCycle"),uncaught=require("../uncaught"),isNodeVersionEOL=require("../util/eol")["isNodeVersionEOL"],ELEVEN_MINUTES=66e4,TEN_MINUTES=6e5;let autoprofile,profiler,logger;if(logger=require("../logger").getLogger("announceCycle/agentready",newLogger=>{logger=newLogger}),agentOpts.autoProfile)try{autoprofile=require("@supertenant/autoprofile")}catch(e){logger.info("Could not load @supertenant/autoprofile. You will not get profiling information for this Node.js app in Instana, although autoprofiling has been enabled. This typically occurs when native addons could not be built during module installation (npm install/yarn) or when npm install --no-optional or yarn --ignore-optional have been used to install dependencies. See the instructions to learn more about the requirements of the collector: https://www.ibm.com/docs/de/obi/current?topic=nodejs-collector-installation#native-add-ons"),fireMonitoringEvent(),setInterval(fireMonitoringEvent,6e5).unref()}let ctx,tracingMetricsDelay=1e3,tracingMetricsTimeout=("string"==typeof process.env.INSTANA_TRACER_METRICS_INTERVAL&&(tracingMetricsDelay=parseInt(process.env.INSTANA_TRACER_METRICS_INTERVAL,10),isNaN(tracingMetricsDelay)||tracingMetricsDelay<=0)&&(tracingMetricsDelay=1e3),null);function enter(_ctx){ctx=_ctx,initializedTooLate.check(),isMainThread&&(uncaught.activate(),metrics.activate(),requestHandler.activate(),transmissionCycle.activate(metrics,agentConnection,function(requests){requestHandler.handleRequests(requests)},function(){ctx.transitionTo("unannounced")}),scheduleTracingMetrics(),detectEOLNodeVersion()),tracing.activate(agentOpts.config),agentOpts.autoProfile&&autoprofile&&((profiler=autoprofile.start()).sendProfiles=(profiles,callback)=>{agentConnection.sendProfiles(profiles,callback)},profiler.getExternalPid=()=>pidStore.pid,profiler.getLogger=()=>logger,profiler.start()),logger.info("The Instana Node.js collector is now fully initialized.")}function leave(){isMainThread&&(uncaught.deactivate(),metrics.deactivate(),requestHandler.deactivate(),transmissionCycle.deactivate(),deScheduleTracingMetrics()),tracing.deactivate(),profiler&&(profiler.destroy(),profiler=null)}function sendTracingMetrics(){var payload=tracing._getAndResetTracingMetrics();agentConnection.sendTracingMetricsToAgent(payload,error=>{error&&(logger.warn("Error received while trying to send tracing metrics to agent: %s",error.message),"string"==typeof error.message)&&error.message.indexOf("Got status code 404")?logger.warn("Apparently the agent does not support POST /tracermetrics, will stop sending tracing metrics."):scheduleTracingMetrics()})}function scheduleTracingMetrics(){(tracingMetricsTimeout=setTimeout(sendTracingMetrics,tracingMetricsDelay)).unref()}function deScheduleTracingMetrics(){tracingMetricsTimeout&&(clearTimeout(tracingMetricsTimeout),tracingMetricsTimeout=null)}function fireMonitoringEvent(){agentConnection.sendAgentMonitoringEvent("nodejs_collector_native_addon_autoprofile_missing","PROFILER",error=>{error&&logger.error("Error received while trying to send Agent Monitoring Event to agent: %s",error.message)})}function sendEOLEvent(){agentConnection.sendEvent({title:`Node.js version ${process.versions.node} reached its end of life`,text:"This version no longer receives updates or security fixes and might contain unfixed vulnerabilities.\n\nPlease consider upgrading Node.js to an active version.\n\nFor a list of active versions visit [https://nodejs.org/en/about/releases/](https://nodejs.org/en/about/releases/)",plugin:"com.instana.forge.infrastructure.runtime.nodejs.NodeJsRuntimePlatform",id:pidStore&&"function"==typeof pidStore.getEntityId?pidStore.getEntityId():void 0,timestamp:Date.now(),duration:ELEVEN_MINUTES,severity:agentConnection.AgentEventSeverity.WARNING},err=>{err&&logger.debug("Node.js version EOL",err)})}function detectEOLNodeVersion(){isNodeVersionEOL()&&setTimeout(()=>{sendEOLEvent(),setInterval(sendEOLEvent,TEN_MINUTES).unref()},2e3)}module.exports=exports={enter:enter,leave:leave};