Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the --all option to journald and cleaned up wait groups #414

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions operator/builtin/input/journald/journald.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func (c JournaldInputConfig) Build(buildContext operator.BuildContext) ([]operat
// Export logs as JSON
args = append(args, "--output=json")

// Show all fields without encoding or truncation
args = append(args, "--all")

// Give raw json output and then exit the process
args = append(args, "--no-pager")

Expand Down Expand Up @@ -138,11 +141,12 @@ func (operator *JournaldInput) Start() error {
// checking if there are new files or new logs in the watched files
func (operator *JournaldInput) startPoller(ctx context.Context) {
operator.Debug("starting poller")
go func() {
globTicker := time.NewTicker(operator.pollInterval)
operator.wg.Add(1)
operator.wg.Add(1)

go func() {
defer operator.wg.Done()

globTicker := time.NewTicker(operator.pollInterval)
defer globTicker.Stop()

for {
Expand All @@ -163,9 +167,6 @@ func (operator *JournaldInput) startPoller(ctx context.Context) {

// poll checks all the watched paths for new entries
func (operator *JournaldInput) poll(ctx context.Context) error {
operator.wg.Add(1)

defer operator.wg.Done()
defer operator.syncOffsets()

// Start from a cursor if there is a saved offset
Expand Down