Skip to content

Commit

Permalink
Merge pull request #44 from aiven/reduce-stats-logging
Browse files Browse the repository at this point in the history
stats: reduce logging output

#44 (review)
  • Loading branch information
Mika Eloranta authored Feb 5, 2019
2 parents e5f1fe7 + 9197239 commit 1681af3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions journalpump/journalpump.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ def __init__(self, *, name, config, field_filters, geoip, stats,
self.read_lines = 0
self._last_sent_read_lines = 0
self._last_sent_read_bytes = 0
self._sent_bytes_diff = 0
self._sent_lines_diff = 0
self.last_stats_print_time = time.monotonic()
self.geoip = geoip
self.config = config
self.field_filters = field_filters
Expand Down Expand Up @@ -674,10 +677,14 @@ def inc_line_stats(self, *, journal_lines, journal_bytes):
self.stats.gauge("journal.read_lines", value=self.read_lines, tags=tags)
self.stats.gauge("journal.read_bytes", value=self.read_bytes, tags=tags)
self.last_stats_send_time = now
lines_diff = self.read_lines - self._last_sent_read_lines
bytes_diff = self.read_bytes - self._last_sent_read_bytes
if lines_diff or bytes_diff:
self.log.info("Processed %r journal lines (%r bytes)", lines_diff, bytes_diff)
self._sent_lines_diff += self.read_lines - self._last_sent_read_lines
self._sent_bytes_diff += self.read_bytes - self._last_sent_read_bytes
if now - self.last_stats_print_time > 120:
self.log.info("Processed %r journal lines (%r bytes)", self._sent_lines_diff, self._sent_bytes_diff)
self._sent_lines_diff = 0
self._sent_bytes_diff = 0
self.last_stats_print_time = now

self._last_sent_read_lines = self.read_lines
self._last_sent_read_bytes = self.read_bytes

Expand Down

0 comments on commit 1681af3

Please sign in to comment.