Skip to content

Commit

Permalink
Merge pull request #148 from coroot/log_reader_optimization
Browse files Browse the repository at this point in the history
logs: multilineCollectorTimeout=1s (instead of 100ms)
  • Loading branch information
def authored Nov 29, 2024
2 parents f51d5cc + a1524ba commit 649b1bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions containers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
)

var (
gcInterval = 10 * time.Minute
pingTimeout = 300 * time.Millisecond
gcInterval = 10 * time.Minute
pingTimeout = 300 * time.Millisecond
multilineCollectorTimeout = time.Second
)

type ContainerID string
Expand Down Expand Up @@ -914,7 +915,7 @@ func (c *Container) runLogParser(logPath string) {
return
}
ch := make(chan logparser.LogEntry)
parser := logparser.NewParser(ch, nil, logs.OtelLogEmitter(containerId))
parser := logparser.NewParser(ch, nil, logs.OtelLogEmitter(containerId), multilineCollectorTimeout)
reader, err := logs.NewTailReader(proc.HostPath(logPath), ch)
if err != nil {
klog.Warningln(err)
Expand All @@ -933,7 +934,7 @@ func (c *Container) runLogParser(logPath string) {
klog.Warningln(err)
return
}
parser := logparser.NewParser(ch, nil, logs.OtelLogEmitter(containerId))
parser := logparser.NewParser(ch, nil, logs.OtelLogEmitter(containerId), multilineCollectorTimeout)
stop := func() {
JournaldUnsubscribe(c.cgroup)
}
Expand All @@ -949,7 +950,7 @@ func (c *Container) runLogParser(logPath string) {
delete(c.logParsers, "stdout/stderr")
}
ch := make(chan logparser.LogEntry)
parser := logparser.NewParser(ch, c.metadata.logDecoder, logs.OtelLogEmitter(containerId))
parser := logparser.NewParser(ch, c.metadata.logDecoder, logs.OtelLogEmitter(containerId), multilineCollectorTimeout)
reader, err := logs.NewTailReader(proc.HostPath(c.metadata.logPath), ch)
if err != nil {
klog.Warningln(err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/containerd/cgroups v1.0.4
github.com/containerd/containerd v1.6.26
github.com/coreos/go-systemd/v22 v22.5.0
github.com/coroot/logparser v1.1.5
github.com/coroot/logparser v1.1.6
github.com/docker/docker v25.0.3+incompatible
github.com/florianl/go-conntrack v0.3.0
github.com/go-kit/log v0.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coroot/dotnetdiag v1.2.2 h1:PVP/By8o+xhPjfVolJYcjHLbFQInM7pkaD6/otPLc8Q=
github.com/coroot/dotnetdiag v1.2.2/go.mod h1:veXCMlFzm1yNl7wwJb/ZLxO4WbzhDBoy1VG1XtkH2ls=
github.com/coroot/logparser v1.1.5 h1:gCXeJ0qeRsQWnkK9dOwEiZT3DMjCWp1MTY3ZsPoC3Bk=
github.com/coroot/logparser v1.1.5/go.mod h1:YfYxn9FYBm5GYHHUB4zI22irFAWVDe2bcbOWDHKSmEo=
github.com/coroot/logparser v1.1.6 h1:iMZ7CfKfbSKDD+LayGnd14s9M6/T25/+GKosKYIMoCk=
github.com/coroot/logparser v1.1.6/go.mod h1:YfYxn9FYBm5GYHHUB4zI22irFAWVDe2bcbOWDHKSmEo=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down

0 comments on commit 649b1bf

Please sign in to comment.