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    
@supertenant/collector / src / immediate.js
Size: Mime:
/*
 * (c) Copyright IBM Corp. 2021
 * (c) Copyright Instana Inc. and contributors 2020
 */

'use strict';

const { isNodeJsTooOld, minimumNodeJsVersion } = require('@supertenant/core/src/util/nodeJsVersionCheck');

if (isNodeJsTooOld()) {
  // eslint-disable-next-line no-console
  console.error(
    `The package @supertenant/collector requires at least Node.js ${minimumNodeJsVersion} but this process is ` +
      `running Node.js ${process.version}. This process will not be monitored by Instana.`
  );
  // @ts-ignore TS1108 (return can only be used within a function body)
  return;
}

const { util: coreUtil } = require('@supertenant/core');
const agentOpts = require('./agent/opts');

// This file can be used with NODE_OPTIONS or `node --require` to instrument a Node.js app with Instana without
// modifying the source code. See
// eslint-disable-next-line max-len
// https://www.ibm.com/docs/de/obi/current?topic=nodejs-collector-installation#installation-without-modifying-the-source-code

const isExcludedFromInstrumentation = coreUtil.excludedFromInstrumentation && coreUtil.excludedFromInstrumentation();

// In case this is a child process of an instrumented parent process we might receive the agent uuid from the parent
// process to be able to produce and collect spans immediately without waiting for a connection to the agent in this
// process.
const parentProcessAgentUuid = process.env.INSTANA_AGENT_UUID;

if (!isExcludedFromInstrumentation) {
  if (parentProcessAgentUuid) {
    // @ts-ignore - Type 'string' is not assignable to type 'undefined'
    // Probably because exports.agentUuid is set to undefined and export values were not supposed to be changed
    agentOpts.agentUuid = parentProcessAgentUuid;
    require('./index')({
      tracing: {
        activateImmediately: true,
        activateBullProcessInstrumentation: true,
        forceTransmissionStartingAt: 1
      }
    });
  } else {
    require('./index')();
  }
}