1. Overview
Statistics interface. Declares counters, grouped aggregates and a bounded recent-event log.
The original source path is:
include/bsc/stats/Statistics.hpp
2. Role in the Daemon
This file participates in the privileged BastionGuard Secure Connection daemon. It uses the shared bsc models and follows the daemon-wide fallback strategy: optional high-fidelity backends are used when available, while portable polling or stub behavior preserves service startup.
3. Namespaces
bsc::stats
4. Dependencies and Included Interfaces
bsc/model/Connection.hppcstdintdequemapmutexstring
5. Declared Types
struct Eventclass Statistics
6. State and Data Members
The interface declares the following relevant state members:
std::string timebsc::model::Connection connectionstd::string rule_namemutable std::mutex mutex_std::size_t max_events_std::map<std::string, std::uint64_t> by_proto_std::map<std::string, std::uint64_t> by_address_std::map<std::string, std::uint64_t> by_host_std::map<std::string, std::uint64_t> by_port_std::map<std::string, std::uint64_t> by_uid_std::map<std::string, std::uint64_t> by_executable_std::deque<Event> events_
7. API and Functions
The file declares or implements the following callable entry points:
public: explicit Statistics(std::size_t max_events = 250)void record(const bsc::model::Connection& conn, const std::string& action, const std::string& rule_name)void note_dns_response()explicit Statistics(std::size_t max_events = 250)
8. Recorded Metrics
- Total connections and accepted/dropped/ignored verdicts.
- Rule hit and miss counts and DNS response count.
- Aggregates by protocol, address, hostname, destination port, UID and executable.
- A bounded deque of recent detailed events.
9. External Resources and Protocol Values
Relevant paths, endpoints, command names or policy values referenced by this file include:
bsc/model/Connection.hpp
10. Concurrency and Lifecycle
- Protects mutable shared data with std::mutex.
11. Implementation Considerations
- Shared state is protected by mutexes; callers should avoid holding external locks while invoking callbacks.
12. Source Metrics
| Metric | Value |
|---|---|
| File size | 2131 bytes |
| Lines | 58 |
| Detected API entries | 4 |
| Detected types | 2 |
