Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bmwant/spoor

Track invocations of methods and functions
https://github.com/bmwant/spoor

ab-testing apm data-collection debugging library-tools metrics metrics-gathering performance profiling python statistics summary tools tracing tracking utility

Last synced: 13 days ago
JSON representation

Track invocations of methods and functions

Awesome Lists containing this project

README

        

## spoor

![Tests](https://github.com/bmwant/spoor/actions/workflows/tests.yml/badge.svg)
[![PyPI](https://img.shields.io/pypi/v/spoor)](https://pypi.org/project/spoor/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/spoor)

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![EditorConfig](https://img.shields.io/badge/-EditorConfig-grey?logo=editorconfig)](https://editorconfig.org/)
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)

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

```bash
$ pip install spoor
```

### Usage

```python
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

* [statsd](#)
* [DataDog](#)

### Limitations

* No support for `staticmethod` tracking yet
* No support for `classmethod` tracking yet

### See also

* πŸ’ [podmena](https://github.com/bmwant/podmena) for nice commits emoji
* 🌈 [rich](https://github.com/Textualize/rich) for beautiful terminal output
* πŸ‡ΊπŸ‡¦ [United 24](https://u24.gov.ua/) to support Ukraine in the war