From 426a6a3d9309e3f7cf5fc89d6a687c7895785cc3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 25 Mar 2026 18:44:15 +0000 Subject: Revise stats and add signal handlers to log them and reset them Also logs them on main loop exit. --- src/ingestor.hpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/ingestor.hpp') diff --git a/src/ingestor.hpp b/src/ingestor.hpp index 3f6aa37..fcddc92 100644 --- a/src/ingestor.hpp +++ b/src/ingestor.hpp @@ -64,14 +64,20 @@ namespace WebStat { IngestorSettings settings; + struct Stats { + size_t linesRead; + size_t linesParsed; + size_t linesParseFailed; + size_t logsInserted; + size_t entitiesInserted; + constexpr bool operator==(const Ingestor::Stats &) const = default; + }; + protected: static Ingestor * currentIngestor; DB::ConnectionPoolPtr dbpool; + mutable Stats stats {}; - size_t linesRead = 0; - size_t linesParsed = 0; - size_t linesDiscarded = 0; - size_t linesParked = 0; std::flat_set existingEntities; LineBatch queuedLines; @@ -100,12 +106,16 @@ namespace WebStat { template NewEntities newEntities(const std::tuple &) const; void onNewUserAgent(const Entity &) const; void handleCurlOperations(); + void logStats() const; + void clearStats(); void jobIngestParkedLines(const std::filesystem::path &); size_t jobIngestParkedLines(FILE *, size_t count); static void sigtermHandler(int); void terminate(int); + static void sigusr1Handler(int); + static void sigusr2Handler(int); [[gnu::format(printf, 3, 4)]] virtual void log(int level, const char * msgfmt, ...) const = 0; using CurlOperations = std::map>; -- cgit v1.3