satella.instrumentation.metrics.structures package¶
Submodules¶
satella.instrumentation.metrics.structures.cache_dict module¶
- class satella.instrumentation.metrics.structures.cache_dict.MetrifiedCacheDict(stale_interval, expiration_interval, value_getter, value_getter_executor=None, cache_failures_interval=None, time_getter=<built-in function monotonic>, default_value_factory=None, cache_hits=None, cache_miss=None, refreshes=None, how_long_refresh_takes=None)¶
Bases:
CacheDict
[K
,V
]A CacheDict with metrics!
- Parameters:
cache_hits (Optional[CounterMetric]) – a counter metric that will be updated with +1 each time there’s a cache hit
cache_miss (Optional[CounterMetric]) – a counter metric that will be updated with +1 each time there’s a cache miss
refreshes (Optional[CounterMetric]) – a metric that will be updated with +1 each time there’s a cache refresh
how_long_refresh_takes (Optional[MeasurableMixin]) – a metric that will be ticked with time value_getter took
- class satella.instrumentation.metrics.structures.cache_dict.MetrifiedExclusiveWritebackCache(*args, cache_hits=None, cache_miss=None, entries_waiting=None, **kwargs)¶
Bases:
ExclusiveWritebackCache
[K
,V
]- Parameters:
cache_hits (Optional[CounterMetric]) –
cache_miss (Optional[CounterMetric]) –
entries_waiting (Optional[CallableMetric]) –
- cache_hits¶
- cache_miss¶
- class satella.instrumentation.metrics.structures.cache_dict.MetrifiedLRUCacheDict(stale_interval, expiration_interval, value_getter, value_getter_executor=None, cache_failures_interval=None, time_getter=<built-in function monotonic>, default_value_factory=None, max_size=100, cache_hits=None, cache_miss=None, refreshes=None, how_long_refresh_takes=None, evictions=None, **kwargs)¶
Bases:
LRUCacheDict
[K
,V
]A LRUCacheDict with metrics!
- Parameters:
cache_hits (Optional[Metric]) – a counter metric that will be updated with +1 each time there’s a cache hit
cache_miss (Optional[Metric]) – a counter metric that will be updated with +1 each time there’s a cache miss
refreshes (Optional[Metric]) – a metric that will be updated with +1 each time there’s a cache refresh
how_long_refresh_takes (Optional[MeasurableMixin]) – a metric that will be ticked with time value_getter took
stale_interval (float) –
expiration_interval (float) –
max_size (int) –
evictions (Optional[Metric]) –
- evict()¶
satella.instrumentation.metrics.structures.threadpool module¶
- class satella.instrumentation.metrics.structures.threadpool.MetrifiedThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=(), time_spent_waiting=None, time_spent_executing=None, waiting_tasks=None, metric_level=MetricLevel.RUNTIME)¶
Bases:
ThreadPoolExecutor
A thread pool executor that provides execution statistics as metrics.
This class will also backport some of Python 3.8’s characteristics of the thread pool executor to earlier Pythons, thread name prefix, initializer, initargs and BrokenThreadPool behaviour.
- Parameters:
time_spent_waiting – a metric (can be aggregate) to which times spent waiting in the queue will be deposited
time_spent_executing – a metric (can be aggregate) to which times spent executing will be deposited
waiting_tasks (Optional[CallableMetric]) – a fresh CallableMetric that will be patched to yield the number of currently waiting tasks
metric_level (MetricLevel) – a level with which to log to these two metrics
Initializes a new ThreadPoolExecutor instance.
- Args:
- max_workers: The maximum number of threads that can be used to
execute the given calls.
thread_name_prefix: An optional name prefix to give our threads. initializer: A callable used to initialize worker threads. initargs: A tuple of arguments to pass to the initializer.
- get_queue_length()¶
Return the amount of tasks currently in the queue
- Return type:
int
Module contents¶
- class satella.instrumentation.metrics.structures.MetrifiedCacheDict(stale_interval, expiration_interval, value_getter, value_getter_executor=None, cache_failures_interval=None, time_getter=<built-in function monotonic>, default_value_factory=None, cache_hits=None, cache_miss=None, refreshes=None, how_long_refresh_takes=None)¶
Bases:
CacheDict
[K
,V
]A CacheDict with metrics!
- Parameters:
cache_hits (Optional[CounterMetric]) – a counter metric that will be updated with +1 each time there’s a cache hit
cache_miss (Optional[CounterMetric]) – a counter metric that will be updated with +1 each time there’s a cache miss
refreshes (Optional[CounterMetric]) – a metric that will be updated with +1 each time there’s a cache refresh
how_long_refresh_takes (Optional[MeasurableMixin]) – a metric that will be ticked with time value_getter took
- class satella.instrumentation.metrics.structures.MetrifiedExclusiveWritebackCache(*args, cache_hits=None, cache_miss=None, entries_waiting=None, **kwargs)¶
Bases:
ExclusiveWritebackCache
[K
,V
]- Parameters:
cache_hits (Optional[CounterMetric]) –
cache_miss (Optional[CounterMetric]) –
entries_waiting (Optional[CallableMetric]) –
- cache_hits¶
- cache_miss¶
- class satella.instrumentation.metrics.structures.MetrifiedLRUCacheDict(stale_interval, expiration_interval, value_getter, value_getter_executor=None, cache_failures_interval=None, time_getter=<built-in function monotonic>, default_value_factory=None, max_size=100, cache_hits=None, cache_miss=None, refreshes=None, how_long_refresh_takes=None, evictions=None, **kwargs)¶
Bases:
LRUCacheDict
[K
,V
]A LRUCacheDict with metrics!
- Parameters:
cache_hits (Optional[Metric]) – a counter metric that will be updated with +1 each time there’s a cache hit
cache_miss (Optional[Metric]) – a counter metric that will be updated with +1 each time there’s a cache miss
refreshes (Optional[Metric]) – a metric that will be updated with +1 each time there’s a cache refresh
how_long_refresh_takes (Optional[MeasurableMixin]) – a metric that will be ticked with time value_getter took
stale_interval (float) –
expiration_interval (float) –
max_size (int) –
evictions (Optional[Metric]) –
- evict()¶
- class satella.instrumentation.metrics.structures.MetrifiedThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=(), time_spent_waiting=None, time_spent_executing=None, waiting_tasks=None, metric_level=MetricLevel.RUNTIME)¶
Bases:
ThreadPoolExecutor
A thread pool executor that provides execution statistics as metrics.
This class will also backport some of Python 3.8’s characteristics of the thread pool executor to earlier Pythons, thread name prefix, initializer, initargs and BrokenThreadPool behaviour.
- Parameters:
time_spent_waiting – a metric (can be aggregate) to which times spent waiting in the queue will be deposited
time_spent_executing – a metric (can be aggregate) to which times spent executing will be deposited
waiting_tasks (Optional[CallableMetric]) – a fresh CallableMetric that will be patched to yield the number of currently waiting tasks
metric_level (MetricLevel) – a level with which to log to these two metrics
Initializes a new ThreadPoolExecutor instance.
- Args:
- max_workers: The maximum number of threads that can be used to
execute the given calls.
thread_name_prefix: An optional name prefix to give our threads. initializer: A callable used to initialize worker threads. initargs: A tuple of arguments to pass to the initializer.
- get_queue_length()¶
Return the amount of tasks currently in the queue
- Return type:
int