From 70a224923a7e0f401fdd815975b47aeb6ce7d05f Mon Sep 17 00:00:00 2001 From: XXX Date: Wed, 19 Mar 2025 11:14:39 +0900 Subject: [PATCH 1/2] [bug-fix] Make it possible to grant xray traces with an http request in Nuxt3 --- src/plugins/utils/http-utils.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/utils/http-utils.ts b/src/plugins/utils/http-utils.ts index bfd491b3..f623a024 100644 --- a/src/plugins/utils/http-utils.ts +++ b/src/plugins/utils/http-utils.ts @@ -168,10 +168,17 @@ export const addAmznTraceIdHeaderToInit = ( if (!init.headers) { init.headers = {}; } - (init.headers as any)[X_AMZN_TRACE_ID] = getAmznTraceIdHeaderValue( - traceId, - segmentId - ); + if ((init.headers as any).set) { + (init.headers as any).set( + X_AMZN_TRACE_ID, + getAmznTraceIdHeaderValue(traceId, segmentId) + ); + } else { + (init.headers as any)[X_AMZN_TRACE_ID] = getAmznTraceIdHeaderValue( + traceId, + segmentId + ); + } }; export const addAmznTraceIdHeaderToHeaders = ( From 914898952d82bdb52bdb8029971551f64c7f533a Mon Sep 17 00:00:00 2001 From: XXX Date: Sun, 30 Mar 2025 13:24:27 +0900 Subject: [PATCH 2/2] Added tests that make it possible to grant xray traces with an http request in Nuxt3 --- app/http_fetch_event.html | 27 +++++++++++- src/__smoke-test__/dataplane-integ.spec.ts | 39 ++++++++++++++++ .../__integ__/FetchPlugin.test.ts | 29 ++++++++++++ .../utils/__tests__/http-utils.test.ts | 44 ++++++++++++++++++- 4 files changed, 136 insertions(+), 3 deletions(-) diff --git a/app/http_fetch_event.html b/app/http_fetch_event.html index 2847d775..5ca235c3 100644 --- a/app/http_fetch_event.html +++ b/app/http_fetch_event.html @@ -5,8 +5,18 @@