XRay has problems recording subsegments when await keyword is used
- Dominant language
- JavaScript
- Stars
- 280
- Forks
- 157
- PR merge metrics
- No merged PRs in 30d
Description
I have a method with a code similar to the code below were I used await method when calling pool.query() which is a pg pool method. The subsegment that is after the pool.query() never gets recorded but the code execute correctly. It returns that actual rows without any problem.
import {Pool} from 'pg';
import format from "pg-format"
const poolConfig = {
database:
host: ,
port: ,
user: ,
password:
}
pool = new Pool(poolConfig)
export const getDynamicLinkStats = async () => {
return await AWSXRay.captureAsyncFunc('Query-creation-and-postgres-call', async
function(subsegment){
const textQuery = ;
subsegment.addAnnotation('test', '1');
try {
const { rows } = await pool.query(textQuery);
subsegment.addAnnotation('test2', '2');
return rows;
} catch(error) {
return [];
} finally {
subsegment.close();
}
});
};
Contributor guide
Research direction
Start by reproducing the example through AWSXRay.captureAsyncFunc with a pg Pool query, then inspect how the async callback and subsegment lifecycle behave across await. Done means the annotation after pool.query() and the surrounding subsegment are recorded reliably while the query still returns its rows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, node.js, postgresql
- Domain
- backend, databases, observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100