Skip to content

Commit

Permalink
journal probe: send records for every log message
Browse files Browse the repository at this point in the history
The previous logic concatenates log messages on initial startup, when
the entire journal is read to process existing messages. But doing so
might run into the payload size limit (8KB), and thus fail to create a
record.

Sending one record per log message will ensure that the payload size
remains relatively small, almost always below the 8KB size limit.

Signed-off-by: Patrick McCarty <[email protected]>
  • Loading branch information
phmccarty committed Jan 20, 2017
1 parent ca730b2 commit 6536ecb
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/probes/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ static int read_new_entries(sd_journal *journal)

add_to_payload(data, length);

// For now, we send one record per log message, in case the
// there is a large backlog of messages and we exceed the
// payload size limit (8KB). And ignore errors, hoping that it's
// a transient problem.

if (!send_data(error_class)) {
telem_log(LOG_ERR, "Failed to send data. Ignoring.\n");
return num_entries;
}

num_entries++;
}

Expand Down Expand Up @@ -151,17 +161,11 @@ static bool process_existing_entries(sd_journal *journal)
ret = read_new_entries(journal);
if (ret < 0) {
return false;
}

if (!payload) {
} else if (ret == 0) {
telem_log(LOG_DEBUG, "No existing entries found\n");
return true;
}

if (!send_data(error_class)) {
return false;
}

return true;
}

Expand Down Expand Up @@ -278,10 +282,6 @@ static bool process_journal(void)
} else if (r < 0) {
return false;
}

if (!send_data(error_class)) {
return false;
}
}
}
}
Expand Down

0 comments on commit 6536ecb

Please sign in to comment.