Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi Error Reporting, Custom Report Attrs, and Clean Up
Implemented ability to report multiple apm errors from one log. If a user adds multiple "reportable" error attributes to the log msg (default is "error" & "err"), instead of trying to join the errors into one or discarding one, the apmslog handler will report both errors. Added ability for a user to define what slog attribute keys they want to report as errors. Because there is no standard way in slog to attach an error to a msg log, I wanted to add the ability for the user to decide what is and what is not going to be reported. By default, slog attribute keys that are "error" or "err" are reported, but with the new `WithErrorRecordAttrs(keys)` function a user can define which keys will be reported. Cleaned up `ApmHandler` struct and methods. Since we want the user to use the included `NewApmHandler` function and its functional option functions, I decided to make all Struct fields private. Additionally added a check on if the `ApmHandler`'s `tracer` field is nill before trying to use it. It is still possible for a user to pass in a nil tracer using the `WithTracer` functional option.
- Loading branch information