Skip to content

Conversation

@kirrg001
Copy link
Contributor

I noticed we don't have any ESM tests for Otel integration. Added one to proof its working.

refs #2221

// If we require tedious here, it will load the dependency from the
// node_modules folder of the collector package.
// TODO: https://jsw.ibm.com/browse/INSTA-7722
const tedious = require('../../../../../node_modules/tedious');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I auto-resolved this. We have to ensure we are using the right Tedious instance.
Its better to install Tedious in the local app folder to be 100% sure we are loading the right instance.

@kirrg001 kirrg001 marked this pull request as ready for review December 29, 2025 13:02
@kirrg001 kirrg001 requested a review from a team as a code owner December 29, 2025 13:02
}
execSync('npm install --no-save --no-package-lock --prefix ./ ./core.tgz', {

execSync('npm install --save --prefix ./ ./core.tgz', {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI if we dont use --save, multiple execSync commands will remove previous installations. Using package.json with save + gitignore.

return;
}

execSync('rm package-lock.json', { cwd: __dirname, stdio: 'inherit' });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
execSync('rm package-lock.json', { cwd: __dirname, stdio: 'inherit' });

@kirrg001
Copy link
Contributor Author

ESM true passed

if (process.env.RUN_ESM && !opts.execArgv) {
const esmLoader = [`--import=${path.join(__dirname, '..', '..', 'esm-register.mjs')}`];
const esmLoader = [
`--import=${opts.esmLoaderPath ? opts.esmLoaderPath : path.join(__dirname, '..', '..', 'esm-register.mjs')}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otel integration has its complete own testing space (we dont use anything from outside). Offering a way to specify the esm handler inside the otel app space.

}

execSync('rm -rf package-lock.json', { cwd: __dirname, stdio: 'inherit' });
execSync('rm -rf package.json', { cwd: __dirname, stdio: 'inherit' });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both files in gitignore.

@sonarqubecloud
Copy link

const restifyTest = semver.gte(process.versions.node, '24.0.0') ? describe.skip : describe;
let restifyTest = semver.gte(process.versions.node, '24.0.0') ? describe.skip : describe;

if (process.env.RUN_ESM === 'true') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to manually skip them because currently we don't have a strategy when multiple describes/apps are in one test file and some of them have esm support and some not. Just skipping them manually for now (not ideal).

if (process.env.INSTANA_TEST_SKIP_INSTALLING_DEPS !== 'true') {
const rootPackageJson = require('../../../../../package.json');
const tediousVersion = rootPackageJson.devDependencies.tedious;
execSync(`npm i "tedious@${tediousVersion}" --prefix ./ --save`, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually installing tedious into our otel test application space. Full production simulation. No more require tedious from root.

@kirrg001 kirrg001 merged commit 8e2b5a8 into main Dec 29, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants