Skip to content

Commit 8a13e8e

Browse files
authored
fix(logger): fix esbuild ESM bundler error (#4678)
1 parent 6c65c24 commit 8a13e8e

File tree

14 files changed

+261
-1516
lines changed

14 files changed

+261
-1516
lines changed

package-lock.json

Lines changed: 25 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/commons/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@
110110
"serverless",
111111
"nodejs"
112112
],
113-
"dependencies": {
114-
"@aws/lambda-invoke-store": "0.1.0"
115-
},
116113
"devDependencies": {
117114
"@aws-lambda-powertools/testing-utils": "file:../testing"
118115
}

packages/commons/src/envUtils.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { InvokeStore } from '@aws/lambda-invoke-store';
21
import {
32
POWERTOOLS_DEV_ENV_VAR,
43
POWERTOOLS_SERVICE_NAME_ENV_VAR,
@@ -250,19 +249,15 @@ const getServiceName = (): string => {
250249
};
251250

252251
/**
253-
* Get the AWS X-Ray Trace data from the lambda RIC async context or the `_X_AMZN_TRACE_ID` environment variable.
252+
* Get the AWS X-Ray Trace data from the environment variable.
254253
*
255-
* Checks the async context first and if that returns undefined, falls back to the environment variable
256-
*
257-
* The method parses the value and returns an object with the key-value pairs.
254+
* The method parses the environment variable `_X_AMZN_TRACE_ID` and returns an object with the key-value pairs.
258255
*/
259256
const getXrayTraceDataFromEnv = (): Record<string, string> | undefined => {
260-
const xRayTraceEnv =
261-
InvokeStore.getXRayTraceId() ??
262-
getStringFromEnv({
263-
key: XRAY_TRACE_ID_ENV_VAR,
264-
defaultValue: '',
265-
});
257+
const xRayTraceEnv = getStringFromEnv({
258+
key: XRAY_TRACE_ID_ENV_VAR,
259+
defaultValue: '',
260+
});
266261
if (xRayTraceEnv === '') {
267262
return undefined;
268263
}
@@ -285,22 +280,18 @@ const getXrayTraceDataFromEnv = (): Record<string, string> | undefined => {
285280
/**
286281
* Determine if the current invocation is part of a sampled X-Ray trace.
287282
*
288-
* The AWS X-Ray Trace data is available in either the RIC async context or the `_X_AMZN_TRACE_ID` environment variable has this format:
283+
* The AWS X-Ray Trace data available in the environment variable has this format:
289284
* `Root=1-5759e988-bd862e3fe1be46a994272793;Parent=557abcec3ee5a047;Sampled=1`,
290-
*
291-
* Checks the async context first and if that returns undefined, falls back to the environment variable
292285
*/
293286
const isRequestXRaySampled = (): boolean => {
294287
const xRayTraceData = getXrayTraceDataFromEnv();
295288
return xRayTraceData?.Sampled === '1';
296289
};
297290

298291
/**
299-
* AWS X-Ray Trace id from the lambda RIC async context or the `_X_AMZN_TRACE_ID` environment variable.
300-
*
301-
* Checks the async context first and if that returns undefined, falls back to the environment variable
292+
* Get the value of the `_X_AMZN_TRACE_ID` environment variable.
302293
*
303-
* The AWS X-Ray Trace data has this format:
294+
* The AWS X-Ray Trace data available in the environment variable has this format:
304295
* `Root=1-5759e988-bd862e3fe1be46a994272793;Parent=557abcec3ee5a047;Sampled=1`,
305296
*
306297
* The actual Trace ID is: `1-5759e988-bd862e3fe1be46a994272793`.

0 commit comments

Comments
 (0)