Skip to content

Commit cfdfbf5

Browse files
committed
fix: record error response attributes
1 parent 312bff9 commit cfdfbf5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Serverless Middleware
22

3-
Some helpers for writing API endpoints using AWS Lambda.
3+
A helper for writing APIs using AWS Lambda functions.
4+
5+
### Features
6+
7+
- Dependency injection for easy unit testing.
8+
- Pretty JSON error output, with status codes automatically determined based on error message.
9+
- Easy access to query strings and JSON body properties.
10+
- Serverless warmup plugin support.
11+
- OpenTelemetry support and additional span attributes, for use with [opentelemetry-lambda](https://github.com/open-telemetry/opentelemetry-lambda).
412

513
---
614

@@ -47,6 +55,10 @@ serverless plugin.
4755
Simply install the serverless plugin, no other changes to your code necessary.
4856
The middleware will automatically prevent code execution on warmup requests.
4957

58+
### OpenTelemetry span enrichment
59+
60+
If an active OpenTelemetry span is detected, event and response properties will automatically be added.
61+
5062
<br /><br />
5163

5264
---

src/lib/ApiAdapter.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ class ApiAdapter {
6969
return res;
7070
} catch (error) {
7171
console.error(error);
72+
7273
OpenTelemetry.addSpanErrorAttributes(event, error);
73-
return this.errorConverter.convert(error);
74+
75+
const res = this.errorConverter.convert(error);
76+
OpenTelemetry.addSpanResponseAttributes(event, res);
77+
78+
return res;
7479
}
7580
}
7681

0 commit comments

Comments
 (0)