Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Telemetric

Actions Status PyPI version

This library provides lightweight telemetry for Python projects, collecting statistics on function parameter usage to understand how APIs are being used.

Installation

pip install telemetric

Usage

Automatic Function Wrapping

To automatically track parameter usage statistics for existing Python packages, use the install() function before importing the target modules:

from telemetric import install

# Install telemetry for specific modules
install(["scipy.stats._correlation", "scipy.stats._distn_infrastructure"])

from scipy import stats

# Use functions normally
stats.norm.pdf(x=1, loc=1, scale=0.01)
stats.norm(loc=1, scale=0.02).pdf(1)

# Retrieve statistics for wrapped functions
print("Call counts:", stats.norm.pdf._get_counts())
print("Parameter stats:", stats.norm.pdf._get_param_stats())

The _get_counts() method returns a tuple of:

  • Total function calls
  • Number of calls that raised errors
  • Number of calls with invalid arguments (wrapping issues)

The _get_param_stats() method returns detailed statistics for each parameter:

  • Parameter name (or None for positional-only)
  • Number of times the parameter was passed
  • Tracked parameter values (if specified)
  • Counts for each tracked value (if specified)

Manual Function Decoration

For more control, use the stats_deco_auto decorator to automatically track all parameters:

from telemetric import stats_deco_auto


@stats_deco_auto
def my_function(x, y=10, z="default"):
    return x + y


my_function(5)
my_function(5, y=20)
my_function(5, 20, "custom")

print(my_function._get_counts())
print(my_function._get_param_stats())

For fine-grained control over which parameter values to track, use stats_deco:

from telemetric import stats_deco


@stats_deco(x=None, y=(10, 20, 30), z=("default", "custom"))
def my_function(x, y=10, z="default"):
    return x + y


# The decorator will track:
# - Whether x was passed (any value)
# - How often y was 10, 20, or 30 (and count other values separately)
# - How often z was "default" or "custom" (and count other values separately)

Printing All Statistics

To print a summary of all wrapped functions and their statistics:

from telemetric.statswrapper import print_all_stats

# After your code has run
print_all_stats()

OpenTelemetry Integration (Legacy)

The library also supports OpenTelemetry-based tracing for distributed systems:

from telemetric import span, start_span_processor


@span
def foo(bar):
    print(bar)


if __name__ == "__main__":
    start_span_processor("test-service")
    foo(bar="baz")

OpenTelemetry Collector Setup (Legacy)

If using the OpenTelemetry integration, you can set up collectors for trace data:

To start a collector that prints each log message to stdout:

cd tests/collector
docker run -p 4317:4317 -p 4318:4318 --rm \
  -v $(pwd)/collector-config.yaml:/etc/otelcol/config.yaml \
  otel/opentelemetry-collector

To start a Jaeger collector with a dashboard UI:

docker run --name jaeger \
  -e COLLECTOR_OTLP_ENABLED=true \
  -p 16686:16686 \
  -p 4317:4317 \
  -p 4318:4318 \
  jaegertracing/all-in-one:1.35

Access the Jaeger UI at http://localhost:16686

Metadata

Release files for telemetric 0.0.1rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for telemetric 0.0.1rc1
File Size Uploaded
telemetric-0.0.1rc1.tar.gz 30.3 kB Details

Release files / telemetric-0.0.1rc1.tar.gz

Download URL telemetric-0.0.1rc1.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
103d2f902268a02c704248aa09959f2531e80658658c2ee2ac5326de94706fff
BLAKE2b-256 checksum
How to use checksums
886ba9f9cf539b3fcef06510d6702c4e82d35b461f4ce4e19a11259854749e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.1rc1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page