Track invocation of your functions and methods; display collected statistics for the invocations; export data gathered to external services.
$ pip install spoor
from spoor import Spoor
s = Spoor()
@s.track
def func(a: int, b: int) -> int:
return a + b
func(5, 10)
func(23, 42)
assert s.called(func)
assert s.call_count(func) == 2
Option | Type | Default | Description |
---|---|---|---|
attach |
bool |
False |
Expose called /call_count attributes directly on a function/method object. |
distinct_instances |
bool |
False |
Separate metrics collection for each instance of a class. Has no effect if tracking only functions. |
skip_dunder |
bool |
True |
Do not track double underscore method calls (like __str__ ) for class instances. Has no effect if tracking only functions. |
disabled |
bool |
False |
Initialize as inactive and ignore metrics collection until enabled explicitly. Can be controlled via enable() /disable() methods later. |
- No support for
staticmethod
tracking yet - No support for
classmethod
tracking yet