File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
1
# Serverless Middleware
2
2
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 ) .
4
12
5
13
---
6
14
@@ -47,6 +55,10 @@ serverless plugin.
47
55
Simply install the serverless plugin, no other changes to your code necessary.
48
56
The middleware will automatically prevent code execution on warmup requests.
49
57
58
+ ### OpenTelemetry span enrichment
59
+
60
+ If an active OpenTelemetry span is detected, event and response properties will automatically be added.
61
+
50
62
<br /><br />
51
63
52
64
---
Original file line number Diff line number Diff line change @@ -69,8 +69,13 @@ class ApiAdapter {
69
69
return res ;
70
70
} catch ( error ) {
71
71
console . error ( error ) ;
72
+
72
73
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 ;
74
79
}
75
80
}
76
81
You can’t perform that action at this time.
0 commit comments