File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 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.
4755Simply install the serverless plugin, no other changes to your code necessary.
4856The 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---
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments