You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes a Handler will need to modify a Record before passing it on to another Handler or backend. A Record contains a mixture of simple public fields (e.g. Time, Level, Message) and hidden fields that refer to state (such as attributes) indirectly. This means that modifying a simple copy of a Record (e.g. by calling Record.Add or Record.AddAttrs to add attributes) may have unexpected effects on the original. Before modifying a Record, use Record.Clone to create a copy that shares no state with the original, or create a new Record with NewRecord and build up its Attrs by traversing the old ones with Record.Attrs.
The text was updated successfully, but these errors were encountered:
Fix a bug that could manifest itself when a slog Record is modified
concurrently (A) with our handler.Handle implementation (B). If A
completes before B, then it might overwrite an attribute added by A.
Add test case demonstrating the issue.
Fixes#2918
I noticed that the Go integration for
slog
does not callrec.Clone()
before adding to the record. The documentation forslog
states:The text was updated successfully, but these errors were encountered: