jeremydaly / jeremydaly/lambda-api
Catch errors in metrics
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.5k
- Forks
- 127
- Avg merge
- 31m
- Merged PRs (30d)
- 2
Description
I notice that api errors are not counted as errors in Cloudwatch metrics. I tested it also in Epsagon and it shows success even for functions that throw.
I've tried to get an error with the following code, they all return the correct HTTP code and message, but metrics does not catch them.
I have no middleware for errors.
module.exports.handler = async (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false;
return await api.run(event, context, callback);
};
api.get('/profile/unauthorized', async (req, res) => {
return res.error(401, 'unauthorized');
});
api.get('/profile/error', async (req, res) => {
throw new Error('any error');
});
api.get('/profile/error500', async (req, res) => {
return res.error(500, 'explicit error 500');
});
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the handler and api.run flow shown in the issue, then trace how thrown errors and res.error responses are represented for CloudWatch metrics and Epsagon. Reproduce the three profile routes and verify that unauthorized, explicit 500, and thrown errors are recorded as failures rather than successes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript
- Domain
- api, backend, observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100