Commit 3ec881b
authored
feat: Add tracing support and configurable logging initialization
### **Summary**
This PR introduces comprehensive tracing support alongside the existing env_logger functionality, while making logging initialization configurable and event logging optional.
### **Key Features Added**
#### **🔧 New Feature Flags**
- **`tracing`**: Enables tracing/tracing-subscriber integration as an alternative to env_logger
- **`env_logger`**: Now an optional feature (still enabled by default for backward compatibility)
- **`log`**: Independent log feature flag that controls log statement generation in generated code and the availability of re-exported `log` crate
#### **📝 New Macro Parameters**
- **`log_init = function_name`**: Allows custom log initialization functions instead of relying on defaults
- **`event_logging = bool`**: Controls whether Lambda event payloads are logged (now defaults to `false` for better security)
#### **🚀 Tracing Integration**
- Adds `#[tracing::instrument]` attributes to generated handler functions
- Configures structured JSON logging by default
- Includes request ID and operation name in trace spans
- Aimed at replacing the existing env_logger setup when enabled (but both features can be enabled together)
### **Technical Changes**
#### **Architecture**
- **Feature-aware code generation**: Proc macro now conditionally generates logging code based on enabled features
- **Flexible initialization**: Supports custom logging setup functions with compile-time signature validation
- **Conditional compilation**: Uses cfg attributes to include only relevant logging dependencies
#### **Default Behavior Changes**
- Event payload logging (the event received by the Lambda function) is now disabled by default for security reasons. It must be explicitly enabled by the new `event_logging = bool` macro option.
- When event logging is enabled, events are logged at `debug` level instead of `info`
### **Breaking Changes**
- **Event Logging**: The full dump of the event payload received by the lambda function was always performed, it is now disabled by default (can be re-enabled with `event_logging = true`)
### **Backward Compatibility**
- Default feature set remains `["env_logger"]` ensuring existing code continues to work
- All existing macro parameters and functionality preserved
- Generated code structure unchanged for existing feature combinations
### **Examples Usage**
```rust
// Custom log initialization
appsync_lambda_main!("schema.graphql", log_init = my_custom_logger);
// Enable event logging for debugging
appsync_lambda_main!("schema.graphql", event_logging = true);
```1 parent 1d8fd46 commit 3ec881b
14 files changed
Lines changed: 355 additions & 34 deletions
File tree
- lambda-appsync-proc
- src
- appsync_lambda_main
- tests
- fail
- pass
- lambda-appsync
- src
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
971 | 971 | | |
972 | 972 | | |
973 | 973 | | |
| 974 | + | |
974 | 975 | | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
975 | 984 | | |
976 | 985 | | |
977 | 986 | | |
| |||
980 | 989 | | |
981 | 990 | | |
982 | 991 | | |
983 | | - | |
| 992 | + | |
984 | 993 | | |
985 | 994 | | |
986 | 995 | | |
| |||
0 commit comments