Skip to content

Commit

Permalink
chore: updated debug info, added preload flags
Browse files Browse the repository at this point in the history
  • Loading branch information
abhilash-sivan committed Aug 23, 2024
1 parent e6f1af1 commit 6ea894a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 40 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/tracing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const {
isESMApp
} = require('../util/esm');
const iitmHook = require('../util/iitmHook');
const { getPackageInstallation } = require('../util/getPackageInstallation');
const { getPreloadFlags } = require('../util/getPreloadFlags');

let tracingEnabled = false;
let tracingActivated = false;
Expand Down Expand Up @@ -181,10 +181,10 @@ exports.preInit = function preInit(preliminaryConfig) {
*/
exports.init = function init(_config, downstreamConnection, _processIdentityProvider) {
if (process.env.INSTANA_DEBUG || process.env.INSTANA_LOG_LEVEL === 'debug') {
const method = getPackageInstallation();
const preloadFlags = getPreloadFlags();

// eslint-disable-next-line no-console
console.debug(`The App has instrumented instana using: ${method}`);
console.debug(`The App is using the following preload flags: ${preloadFlags}`);
}

// Consider removing this in the next major release(v4.x) of the @instana package.
Expand Down
37 changes: 0 additions & 37 deletions packages/core/src/util/getPackageInstallation.js

This file was deleted.

21 changes: 21 additions & 0 deletions packages/core/src/util/getPreloadFlags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* (c) Copyright IBM Corp. 2024
*/

'use strict';

exports.getPreloadFlags = function getPreloadFlags() {
if (
process.env.NODE_OPTIONS?.includes('--require')
|| process.env.NODE_OPTIONS?.includes('--import')
|| process.env.NODE_OPTIONS?.includes('--experimental-loader')) {
return process.env.NODE_OPTIONS;
} else if (process.execArgv.length > 0) {
const result = process.execArgv.find(arg =>
arg.includes('--require') || arg.includes('--import') || arg.includes('--experimental-loader')
);
return result || 'noFlags';
} else {
return 'noFlags';
}
};

0 comments on commit 6ea894a

Please sign in to comment.