@adobe/spacecat-shared-utils 1.37.0 → 1.37.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [@adobe/spacecat-shared-utils-v1.37.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.37.1...@adobe/spacecat-shared-utils-v1.37.2) (2025-05-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **xray:** local friendly xray instrumentation ([#714](https://github.com/adobe/spacecat-shared/issues/714)) ([7c7cebd](https://github.com/adobe/spacecat-shared/commit/7c7cebdde4e1c0b24c80201c5d16a68f470122cb))
7
+
8
+ # [@adobe/spacecat-shared-utils-v1.37.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.37.0...@adobe/spacecat-shared-utils-v1.37.1) (2025-05-03)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#712](https://github.com/adobe/spacecat-shared/issues/712)) ([76cebd2](https://github.com/adobe/spacecat-shared/commit/76cebd2a7a7b9799e4ca265833620eada01f5c8c))
14
+
1
15
  # [@adobe/spacecat-shared-utils-v1.37.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.36.3...@adobe/spacecat-shared-utils-v1.37.0) (2025-04-28)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.37.0",
3
+ "version": "1.37.2",
4
4
  "description": "Shared modules of the Spacecat Services - utils",
5
5
  "type": "module",
6
6
  "engines": {
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@adobe/fetch": "4.2.0",
49
- "@aws-sdk/client-s3": "3.797.0",
50
- "@aws-sdk/client-sqs": "3.797.0",
49
+ "@aws-sdk/client-s3": "3.802.0",
50
+ "@aws-sdk/client-sqs": "3.799.0",
51
51
  "@json2csv/plainjs": "7.0.6",
52
52
  "aws-xray-sdk": "3.10.3",
53
53
  "uuid": "11.1.0"
package/src/index.js CHANGED
@@ -49,7 +49,7 @@ export { sqsWrapper } from './sqs.js';
49
49
  export { sqsEventAdapter } from './sqs.js';
50
50
 
51
51
  export { logWrapper } from './log-wrapper.js';
52
- export { xrayWrapper } from './xray.js';
52
+ export { instrumentAWSClient } from './xray.js';
53
53
 
54
54
  export {
55
55
  composeBaseURL,
package/src/s3.js CHANGED
@@ -10,8 +10,8 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import AWSXray from 'aws-xray-sdk';
14
13
  import { S3Client } from '@aws-sdk/client-s3';
14
+ import { instrumentAWSClient } from './xray.js';
15
15
 
16
16
  /**
17
17
  * Adds an S3Client instance and bucket to the context.
@@ -29,7 +29,7 @@ export function s3Wrapper(fn) {
29
29
  S3_BUCKET_NAME: bucket,
30
30
  } = context.env;
31
31
 
32
- context.s3.s3Client = AWSXray.captureAWSv3Client(new S3Client({ region }));
32
+ context.s3.s3Client = instrumentAWSClient(new S3Client({ region }));
33
33
  context.s3.s3Bucket = bucket;
34
34
  }
35
35
 
package/src/sqs.js CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  import { Response } from '@adobe/fetch';
14
14
  import { SendMessageCommand, SQSClient } from '@aws-sdk/client-sqs';
15
- import AWSXray from 'aws-xray-sdk';
15
+ import { instrumentAWSClient } from './xray.js';
16
16
 
17
17
  import { hasText, isNonEmptyArray } from './functions.js';
18
18
 
@@ -30,7 +30,7 @@ function badRequest(message) {
30
30
  */
31
31
  class SQS {
32
32
  constructor(region, log) {
33
- this.sqsClient = AWSXray.captureAWSv3Client(new SQSClient({ region }));
33
+ this.sqsClient = instrumentAWSClient(new SQSClient({ region }));
34
34
  this.log = log;
35
35
  }
36
36
 
@@ -151,13 +151,6 @@ const fetchWithTimeout = async (resource, options, signal) => {
151
151
  * @returns {Promise<Response>} The response from the fetch request.
152
152
  */
153
153
  export async function tracingFetch(url, options) {
154
- // fallback to adobe fetch outside an aws lambda function
155
- if (!isAWSLambda()) {
156
- return adobeFetch;
157
- }
158
-
159
- const parentSegment = AWSXRay.getSegment();
160
-
161
154
  options = isObject(options) ? { ...options } : {};
162
155
  options.headers = isObject(options.headers) ? options.headers : { };
163
156
 
@@ -180,6 +173,13 @@ export async function tracingFetch(url, options) {
180
173
  options.headers['User-Agent'] = SPACECAT_USER_AGENT;
181
174
  }
182
175
 
176
+ // fallback to adobe fetch outside an aws lambda function
177
+ if (!isAWSLambda()) {
178
+ return fetchWithTimeout(url, options, signal);
179
+ }
180
+
181
+ const parentSegment = AWSXRay.getSegment();
182
+
183
183
  // If no parent segment, perform fetch without tracing
184
184
  if (!parentSegment) {
185
185
  return fetchWithTimeout(url, options, signal);
package/src/xray.js CHANGED
@@ -13,16 +13,6 @@
13
13
  import AWSXray from 'aws-xray-sdk';
14
14
  import { isAWSLambda } from './runtimes.js';
15
15
 
16
- export function xrayWrapper(fn) {
17
- return async (req, context) => {
18
- if (context.xray) {
19
- return context.xray;
20
- }
21
-
22
- context.xray = {
23
- instrument: (client) => (isAWSLambda() ? AWSXray.captureAWSv3Client(client) : client),
24
- };
25
-
26
- return fn(req, context);
27
- };
16
+ export function instrumentAWSClient(client) {
17
+ return isAWSLambda() ? AWSXray.captureAWSv3Client(client) : client;
28
18
  }