In the existing code, we create a mapstr.M containing attributes to set in the RootFields of metric events, which is reused several times in a loop. In the publisher code, the root fields are modified, e.g. https://github.com/elastic/beats/blob/main/metricbeat/mb/event.go#L79, which causes a panic due to fatal error: concurrent map iteration and map write, as the same mapstr.M object is still being used in later iterations of the loop.
Proposed commit message
Checklist
[ ] My code follows the style guidelines of this project
[ ] I have commented my code, particularly in hard-to-understand areas
[ ] I have made corresponding changes to the documentation
[ ] I have made corresponding change to the default configuration files
[ ] I have added tests that prove my fix is effective or that my feature works
[ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.
In the existing code, we create a mapstr.M containing attributes to set in the
RootFields
of metric events, which is reused several times in a loop. In the publisher code, the root fields are modified, e.g. https://github.com/elastic/beats/blob/main/metricbeat/mb/event.go#L79, which causes a panic due tofatal error: concurrent map iteration and map write
, as the same mapstr.M object is still being used in later iterations of the loop.Proposed commit message
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
Author's Checklist
How to test this PR locally
Related issues
-
Use cases
Screenshots
Logs