Skip to content

Commit

Permalink
Lock mutex for reading while processing logs (#1931)
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-gaillard authored Oct 29, 2024
1 parent b558c01 commit 2750025
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/component/loki/secretfilter/secretfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func (c *Component) Run(ctx context.Context) error {
case <-ctx.Done():
return nil
case entry := <-c.receiver.Chan():
c.mut.RLock()
// Start processing the log entry to redact secrets
newEntry := c.processEntry(entry)
if c.debugDataPublisher.IsActive(componentID) {
Expand All @@ -154,10 +155,12 @@ func (c *Component) Run(ctx context.Context) error {
for _, f := range c.fanout {
select {
case <-ctx.Done():
c.mut.RUnlock()
return nil
case f.Chan() <- newEntry:
}
}
c.mut.RUnlock()
}
}
}
Expand Down

0 comments on commit 2750025

Please sign in to comment.