Closed PolestarTommy closed 1 year ago
Hi @PolestarTommy, Did you see any errors when using axios or were the traces just not showing in the X-Ray console?
I followed your example to reproduce the issue on my end but I was able to see traces in my X-Ray console. I modified the imports to only require axios
after AWSXRay.capturePromise()
and kept all the other imports for http
and https
modules before that line, which follows the example we have in the docs for capturing axios requests
const AWSXRay = require('aws-xray-sdk');
const express = require('express');
// Capture all outgoing https requests
AWSXRay.captureHTTPsGlobal(require('https'));
const https = require('https');
AWSXRay.capturePromise();
const AxiosWithXray = require('axios');
and I used a very simple express endpoint with axios to send a request to aws.amazon.com
:
app.get('/http-call-aws/', async (req, res) => {
const endpoint = 'https://aws.amazon.com/';
await AxiosWithXray.get(endpoint);
res.send(`Successfully reached ${endpoint}.`);
});
and I was able to see the subsegment in X-Ray:
Hope some of this information helps! If you're still not able to see traces for axios requests, maybe enable debug logging in the X-Ray daemon and share those logs here to see if there's another issue causing this to happen?
Hi @carolabadeer
Thank you very much , xray is works with axios , I use this address https://aws.com
,the http response code is 301 , so that is why my case dones't work , thanks again
Hi X-Ray team
I want to use X-ray in our service, I try to capture the http/https/node-fetch packages, it works, but when I try to use the axios package, it doesn't work, I wonder why
Here is a sample
package version list "http": "0.0.1-security", "https": "^1.0.0", "aws-xray-sdk": "^3.4.1", "axios": "^1.2.1", "express": "^4.18.2", "node-fetch": "^2.6.7",