Skip to content

Commit

Permalink
fix(shared-metrics): replaced fs-extra with fs promises (#1362)
Browse files Browse the repository at this point in the history
- Native `fs.promises.cp` available in Node.js 18+. 
- See: https://nodejs.org/api/fs.html#fspromisescpsrc-dest-options
- refs INSTA-786
  • Loading branch information
aryamohanan committed Oct 14, 2024
1 parent 11dd952 commit c8b96bb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 42 deletions.
39 changes: 4 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/collector/test/tracing/database/db2/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,10 @@ mochaSuiteFn('tracing/db2', function () {
.then(() =>
testUtils.retry(() =>
verifySpans(agentControls, controls, {
numberOfSpans: 14,
numberOfSpans: 15,
// Spans:
// 10 queries splitted from the file
// 4 fs operations on top (ours + from db2 internally fs-extra)
// 5 fs operations on top (ours + from db2 internally fs-extra)
// https://github.com/ibmdb/node-ibm_db/blob/fb25937524d74d25917e9aa67fb4737971317986/lib/odbc.js#L916
// If the Otel integration is disabled, we expect 11 spans.
verifyCustom: (entrySpan, spans) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/shared-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@
"@instana/core": "3.20.2",
"detect-libc": "^2.0.2",
"event-loop-lag": "^1.4.0",
"fs-extra": "^11.2.0",
"semver": "^7.5.4",
"tar": "^6.2.1"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/tar": "^6.1.6",
"event-loop-stats": "1.4.1",
"gcstats.js": "1.0.0"
Expand Down
5 changes: 2 additions & 3 deletions packages/shared-metrics/src/util/nativeModuleRetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const os = require('os');
const tar = require('tar');
const path = require('path');
const detectLibc = require('detect-libc');
const fse = require('fs-extra');

/**
* @typedef {Object} InstanaSharedMetricsOptions
Expand Down Expand Up @@ -188,8 +187,8 @@ function copyPrecompiled(opts, loaderEmitter, callback) {
`Copying the precompiled build for ${opts.nativeModuleName} ${label} from ${sourceDir} to ${targetDir}.`
);

fse
.copy(sourceDir, targetDir)
fs.promises
.cp(sourceDir, targetDir, { recursive: true })
.then(() => {
// We have unpacked and copied the correct precompiled native addon. The next attempt to require the
// dependency should work.
Expand Down

0 comments on commit c8b96bb

Please sign in to comment.