aws / aws-xray-sdk-node

The official AWS X-Ray SDK for Node.js.
Apache License 2.0
266 stars 155 forks source link

Support undici #622

Open tenjaa opened 10 months ago

tenjaa commented 10 months ago

Undici is the new official node http client. When trying xray on a Node-18-Lambda while using undici I get an error.

There is an issue on undicis side (https://github.com/nodejs/undici/issues/2190) about not working with xray. They refer to use the diagnostics channel.

import {captureHTTPsGlobal} from 'aws-xray-sdk';
import * as http from 'http';
import * as https from 'https';

captureHTTPsGlobal(http);
captureHTTPsGlobal(https);
2023-10-22T11:24:52.170Z    undefined   ERROR   Uncaught Exception  {
    "errorType": "TypeError",
    "errorMessage": "Cannot add property __request, object is not extensible",
    "stack": [
        "TypeError: Cannot add property __request, object is not extensible",
        "    at enableCapture (file:///var/task/index.mjs:34012:25)",
        "    at captureHTTPsGlobal3 (file:///var/task/index.mjs:33900:9)",
        "    at file:///var/task/index.mjs:35587:44",
        "    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)"
    ]
}
wangzlei commented 8 months ago

undici support is in X-Ray nodejs SDK backlog, but we don't have specific timeline due to resource constrains. Now xray service is able to work with OpenTelemetry, for customers need new libraries support at the moment, we recommend customers onboard opentelemetry Refer to OpenTelemetry undici support: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1021