Skip to main content

Python library for tracing function calls and performance

Project description

  _____                    __
_/ ____\_ __  ____   _____/  |_____________    ____  ____
\   __\  |  \/    \_/ ___\   __\_  __ \__  \ _/ ___\/ __ \
 |  | |  |  /   |  \  \___|  |  |  | \// __ \\  \__\  ___/
 |__| |____/|___|  /\___  >__|  |__|  (____  /\___  >___  >
                 \/     \/                 \/     \/    \/

functrace is a Python library for detailed function call tracing. It provides logging and performance tracking to help monitor execution, measure timing, and debug effectively.

Getting Started

To begin using functrace, you'll first need to install it. This can be easily done using pip. Simply run the following command to install the package:

pip install functrace

Quick Start

Get up and running with functrace quickly by following this simple example. Below is a basic usage scenario to help you integrate functrace into your project and start tracing function calls.

from functrace import TraceResult, trace

def trace_callback(result: TraceResult) -> None:
    function_call = result.function_call.format()
    elapsed_time = result.elapsed_time.format()
    returned_value = repr(result.returned_value)
    exception = repr(result.exception)
    parts = [function_call]
    if result.is_started:
        parts.extend(['Started'])
    if result.is_completed:
        parts.extend(['Completed', elapsed_time, returned_value])
    if result.is_failed:
        parts.extend(['Failed', elapsed_time, exception])
    message = ' | '.join(parts)
    print(message)

@trace(callback=trace_callback)
def func(a, b, c):
    return a, b, c

if __name__ == '__main__':
    func(1, 2, 3)
    # func(a=1, b=2, c=3) | Started
    # func(a=1, b=2, c=3) | Completed | 1 microsecond, 200 nanoseconds | (1, 2, 3)

Summary

You can find functrace on PyPI for installation and package details. For comprehensive documentation and usage guides, visit Read the Docs. For source code and contributions, check out the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

functrace-0.0.4.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

functrace-0.0.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file functrace-0.0.4.tar.gz.

File metadata

  • Download URL: functrace-0.0.4.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for functrace-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c4cd9db875280f20f8e6b703289e4f23ddc27bf71f9bc4496677fcb081e63ba8
MD5 4c652615594fd1caed33874bf00a12ea
BLAKE2b-256 875f599f032aa060d44112c52a6994e4fa8805c5c813e83b4c1c766e2290aca7

See more details on using hashes here.

File details

Details for the file functrace-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: functrace-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for functrace-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 75398ad37e6743efd02b420f019db848a54291fd82dfceb1d10586f066c4620d
MD5 134144a87d939951800ae35d69833e65
BLAKE2b-256 bc5051cf66c58160dac17fa8010b3d4095e0cf16f93da1770171f9f4456be6fc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page