Skip to content

Commit

Permalink
fix(otelcol/fanoutconsumer): nil check during fanout consumer creation (
Browse files Browse the repository at this point in the history
#5854)

Signed-off-by: hainenber <[email protected]>
  • Loading branch information
hainenber authored Nov 27, 2023
1 parent a2348a0 commit 84344fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Main (unreleased)

- Fix issue with windows_exporter defaults not being set correctly. (@mattdurham)

- Fix agent crash when process null OTel's fan out consumers. (@hainenber)

v0.38.0 (2023-11-21)
--------------------

Expand Down
14 changes: 10 additions & 4 deletions component/otelcol/internal/fanoutconsumer/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func Logs(in []otelcol.Consumer) otelconsumer.Logs {
for i := 0; i < len(in)-1; i++ {
consumer := in[i]

if consumer == nil {
continue
}

if consumer.Capabilities().MutatesData {
clone = append(clone, consumer)
} else {
Expand All @@ -40,10 +44,12 @@ func Logs(in []otelcol.Consumer) otelconsumer.Logs {

// The final consumer can be given to the passthrough list regardless of
// whether it mutates as long as there's no other read-only consumers.
if len(passthrough) == 0 || !last.Capabilities().MutatesData {
passthrough = append(passthrough, last)
} else {
clone = append(clone, last)
if last != nil {
if len(passthrough) == 0 || !last.Capabilities().MutatesData {
passthrough = append(passthrough, last)
} else {
clone = append(clone, last)
}
}

return &logsFanout{
Expand Down

0 comments on commit 84344fb

Please sign in to comment.