cosmo
cosmo copied to clipboard
feat: improve error access logs
Motivation and Context
This PR enhances our GraphQL router’s logging and error pipelines, giving you fine-grained control over access-log verbosity, richer diagnostics in both router and subgraph logs, and tidier error propagation.
🎯 What’s Changed
-
Configurable Access-Log Level
- Now you can set
"level"to control which requests get logged ("info"vs"error").
- Now you can set
-
Optional Stack Traces
- The new
"add_stacktrace"flag lets you include full stack traces in your access logs when errors occur.
- The new
-
New
response_errorcontext field- This field will log the response errors as JSON array and includes verbose information including stacktraces about all errors.
-
Cleaner Error Composition
- Resolver errors now propagate intact into the final GraphQL error payload, and we’ve removed an accidental “double join” that was duplicating messages.
⚙️ JSON Config Example
access_logs:
enabled: true
add_stacktrace: true
level: error
router:
fields:
- key: "response_error"
value_from:
context_field: response_error
subgraphs:
enabled: true
fields:
- key: "response_error"
value_from:
context_field: response_error
In this snippet:
"level": "error"ensures only failed operations are emitted."add_stacktrace": true"appends the stack trace for any error.- Field
response_errorwill log the response errors in JSON format including stacktrace information.
Related https://github.com/wundergraph/graphql-go-tools/pull/1132
Checklist
- [ ] I have discussed my proposed changes in an issue and have received approval to proceed.
- [ ] I have followed the coding standards of the project.
- [ ] Tests or benchmarks have been added or updated.
- [ ] Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
- [ ] I have read the Contributors Guide.