From d44107d5716e4ccae411e98ce9d03c00225ce88c Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Thu, 16 Mar 2023 22:20:44 +0100 Subject: [PATCH] fix(resources): change fs/promises import to be node 12 compatible (#3681) * fix(resources): change fs/promises import to be node 12 compatible * fix(changelog): add changelog entry. --- CHANGELOG.md | 3 +++ .../src/platform/node/machine-id/getMachineId-bsd.ts | 2 +- .../src/platform/node/machine-id/getMachineId-linux.ts | 2 +- .../test/detectors/node/machine-id/getMachineId-bsd.test.ts | 2 +- .../test/detectors/node/machine-id/getMachineId-linux.test.ts | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dadea5cc4c..e9182e0f1de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ ### :bug: (Bug Fix) +* fix(resource): make properties for async resource resolution optional [#3677](/~https://github.com/open-telemetry/opentelemetry-js/pull/3677) @pichlermarc +* fix(resource): change fs/promises import to be node 12 compatible [#3681](/~https://github.com/open-telemetry/opentelemetry-js/pull/3681) @pichlermarc + ### :books: (Refine Doc) ### :house: (Internal) diff --git a/packages/opentelemetry-resources/src/platform/node/machine-id/getMachineId-bsd.ts b/packages/opentelemetry-resources/src/platform/node/machine-id/getMachineId-bsd.ts index edd04c7f1be..eb6dd1be415 100644 --- a/packages/opentelemetry-resources/src/platform/node/machine-id/getMachineId-bsd.ts +++ b/packages/opentelemetry-resources/src/platform/node/machine-id/getMachineId-bsd.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as fs from 'fs/promises'; +import { promises as fs } from 'fs'; import { execAsync } from './execAsync'; import { diag } from '@opentelemetry/api'; diff --git a/packages/opentelemetry-resources/src/platform/node/machine-id/getMachineId-linux.ts b/packages/opentelemetry-resources/src/platform/node/machine-id/getMachineId-linux.ts index 74b145a2f4d..9ebfe58e81a 100644 --- a/packages/opentelemetry-resources/src/platform/node/machine-id/getMachineId-linux.ts +++ b/packages/opentelemetry-resources/src/platform/node/machine-id/getMachineId-linux.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import * as fs from 'fs/promises'; +import { promises as fs } from 'fs'; import { diag } from '@opentelemetry/api'; export async function getMachineId(): Promise { diff --git a/packages/opentelemetry-resources/test/detectors/node/machine-id/getMachineId-bsd.test.ts b/packages/opentelemetry-resources/test/detectors/node/machine-id/getMachineId-bsd.test.ts index 317132a9688..ba60b1a9441 100644 --- a/packages/opentelemetry-resources/test/detectors/node/machine-id/getMachineId-bsd.test.ts +++ b/packages/opentelemetry-resources/test/detectors/node/machine-id/getMachineId-bsd.test.ts @@ -16,7 +16,7 @@ import * as sinon from 'sinon'; import * as assert from 'assert'; -import * as fs from 'fs/promises'; +import { promises as fs } from 'fs'; import { PromiseWithChild } from 'child_process'; import * as util from '../../../../src/platform/node/machine-id/execAsync'; import { getMachineId } from '../../../../src/platform/node/machine-id/getMachineId-bsd'; diff --git a/packages/opentelemetry-resources/test/detectors/node/machine-id/getMachineId-linux.test.ts b/packages/opentelemetry-resources/test/detectors/node/machine-id/getMachineId-linux.test.ts index d8dfe4d1dae..41526db379e 100644 --- a/packages/opentelemetry-resources/test/detectors/node/machine-id/getMachineId-linux.test.ts +++ b/packages/opentelemetry-resources/test/detectors/node/machine-id/getMachineId-linux.test.ts @@ -16,7 +16,7 @@ import * as sinon from 'sinon'; import * as assert from 'assert'; -import * as fs from 'fs/promises'; +import { promises as fs } from 'fs'; import { getMachineId } from '../../../../src/platform/node/machine-id/getMachineId-linux';