generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
Which web client version did you detect this bug with?
v1.21.0
What environment (build systems, module system, and framework) did you detect this bug with?
nodejs 23.8.0
Nuxt3
ofetch 1.4.1
Is your web application a single page application (SPA) or multi page application (MPA)?
SPA
Please provide your web client configuration
import { AwsRum, type AwsRumConfig } from 'aws-rum-web';
export default defineNuxtPlugin((_nuxtApp) => {
const runtimeConfig = useRuntimeConfig();
if (runtimeConfig.public.rumEnabled) {
const config: AwsRumConfig = {
sessionSampleRate: 1,
identityPoolId: runtimeConfig.public.rumIdentityPoolId,
endpoint: runtimeConfig.public.rumEndpoint,
telemetries: ["performance", "errors", ['http', { addXRayTraceIdHeader: true, recordAllRequests: true, }]],
allowCookies: true,
enableXRay: true,
sessionEventLimit: -1,
};
const APPLICATION_ID: string = runtimeConfig.public.rumApplicationId;
const APPLICATION_VERSION: string = '1.0.0';
const APPLICATION_REGION: string = runtimeConfig.public.rumApplicationRegion;
const awsRum: AwsRum = new AwsRum(
APPLICATION_ID,
APPLICATION_VERSION,
APPLICATION_REGION,
config
);
return {
provide: {
awsRum: awsRum
}
};
}
});
Please describe the bug/issue
In Nuxt3, X-Amzn-Trace-Id is not added to the http request even if addXrayTraceIdHeader: true is specified.
As a result of debugging, addamznTraceIdHeaderToInit was reached and given by
init.headers [X_AMZN_TRACE_ID] = getAmznTraceIdHeaderValue (traceId, segmentID);,
But X-Amzn-Trace-Id has not actually reached the server. A similar phenomenon has been confirmed in Chrome's Developer Tool > Network.
Nuxt3 uses ofetch as standard, but it seems that the problem with this problem is that there is a difference between the ofetch header reading method and the addAMZntraceidHeaderToInit header method.
Currently,
addamZnTraceIdHeaderToInit = function (init, traceId, segmentId) {
if (! init.headers) {
init.headers = {};
}
init.headers [X_AMZN_TRACE_ID] = getAMZnTraceIdHeaderValue (traceID, segmentID);
};
Headers are set as init.headers properties like this, but init.headers is a Header class,
init.headers.set (X_AMZN_TRACE_ID, getAMZnTraceIdHeaderValue (traceID, segmentID));
You need to change it to.
In fact, headers were added when usinginit.headers.set.
Metadata
Metadata
Assignees
Labels
No labels