dank_mids.stats package
Submodules
dank_mids.stats.retry module
- class dank_mids.stats.retry.StatsRetryObserver
Bases:
objectRetry observer that records events into a stats collector.
When the provided collector lacks retry fields (for example, when the compiled stats module is imported), the observer falls back to an internal in-memory collector so retry handling does not raise AttributeError.
This observer intentionally does not auto-register itself. Wire it up explicitly via
dank_mids.retry_observer.register_retry_observer().- __call__(event)
Call self as a function.
- Parameters:
event (RetryEvent)
- Return type:
None
- __init__(collector=None)
- Parameters:
collector (_RetryCollector | None)
- Return type:
None
Module contents
stats.py
This module provides functionality for logging and collecting statistics related to the Dank Mids library. It includes custom logging levels, a specialized logger, and classes for collecting and writing statistics.
Key components: - Custom logging levels (STATS, DEVHINT) - _StatsLogger: A specialized logger for Dank Mids statistics - _Collector: Handles collection and computation of stats-related data - _Writer: Converts collected stats into human-readable format - _SentryExporter: Pushes metrics to Sentry
This module is crucial for debugging, performance monitoring, and optimization of the Dank Mids library.
- dank_mids.stats.devhint(msg, *args, **kwargs)
Log a message with the DEVHINT logging level.
- Parameters:
- Return type:
None
Example
>>> _logger.devhint("This is a developer hint for debugging purposes")
- dank_mids.stats.log(msg, *args, **kwargs)
Log a message with the STATS logging level.
- Parameters:
- Return type:
None
Example
>>> _logger.stats("Operation took %s seconds", 3.14)
- dank_mids.stats.log_duration(work_descriptor, start, *, level=13)
Log the duration of a specific operation.
- dank_mids.stats.log_errd_batch(batch)
Log information about a failed JSON-RPC batch.
- Parameters:
batch (JSONRPCBatch) – The failed batch to log.
- Return type:
None