bmwant / spoor

Track invocations of methods and functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spoor

Tests PyPI PyPI - Python Version

pre-commit Code style: black EditorConfig semantic-release: angular

Track invocation of your functions and methods; display collected statistics for the invocations; export data gathered to external services.

$ pip install spoor

Usage

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

Configuration

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.

Exporters

Limitations

  • No support for staticmethod tracking yet
  • No support for classmethod tracking yet

See also

  • ๐Ÿ’ podmena for nice commits emoji
  • ๐ŸŒˆ rich for beautiful terminal output
  • ๐Ÿ‡บ๐Ÿ‡ฆ United 24 to support Ukraine in the war

About

Track invocations of methods and functions


Languages

Language:Python 98.5%Language:Makefile 1.5%