Skip to main content

OpenTelemetry-based Python client for tracing functions and sending traces to the AIQA server

Project description

A Python client for the AIQA server

OpenTelemetry-based client for tracing Python functions and sending traces to the AIQA server.

Installation

From PyPI (recommended)

pip install aiqa-client

From source

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install -e .

See TESTING.md for detailed testing instructions.

Setup

Set the following environment variables:

export AIQA_SERVER_URL="http://localhost:3000"
export AIQA_API_KEY="your-api-key"

Usage

Basic Usage

from aiqa import WithTracing

@WithTracing
def my_function(x, y):
    return x + y

@WithTracing
async def my_async_function(x, y):
    await asyncio.sleep(0.1)
    return x * y

Custom Span Name

@WithTracing(name="custom_span_name")
def my_function():
    pass

Input/Output Filtering

@WithTracing(
    filter_input=lambda x: {"filtered": str(x)},
    filter_output=lambda x: {"result": x}
)
def my_function(data):
    return {"processed": data}

Flushing Spans

Spans are automatically flushed every 5 seconds. To flush immediately:

from aiqa import flush_spans
import asyncio

async def main():
    # Your code here
    await flush_spans()

asyncio.run(main())

Shutting Down

To ensure all spans are sent before process exit:

from aiqa import shutdown_tracing
import asyncio

async def main():
    # Your code here
    await shutdown_tracing()

asyncio.run(main())

Setting Span Attributes and Names

from aiqa import set_span_attribute, set_span_name

def my_function():
    set_span_attribute("custom.attribute", "value")
    set_span_name("custom_span_name")
    # ... rest of function

Features

  • Automatic tracing of function calls (sync and async)
  • Records function inputs and outputs as span attributes
  • Automatic error tracking and exception recording
  • Thread-safe span buffering and auto-flushing
  • OpenTelemetry context propagation for nested spans

Example

See example.py for a complete working example.

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

aiqa_client-0.1.5.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiqa_client-0.1.5-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file aiqa_client-0.1.5.tar.gz.

File metadata

  • Download URL: aiqa_client-0.1.5.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for aiqa_client-0.1.5.tar.gz
Algorithm Hash digest
SHA256 6dbaa6fa4fb766f89c7850d325d13f490db8507e11682761f7f09c4ab0c74f16
MD5 8de13417ac7fcd0f3e00beff27a13cb1
BLAKE2b-256 9f0d17dc07e5aa3e10825a1b2c1e4bf7eb84a17a162bffa3bd269cca6b32acb2

See more details on using hashes here.

File details

Details for the file aiqa_client-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: aiqa_client-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for aiqa_client-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3d7314ae30bb97d6ab3df762655817878f5e1c1a5c4c25f03be84d6a164d7a15
MD5 a97dc7aab4610c91addc8273ae4d7858
BLAKE2b-256 6f3f862c3a6c016c6899224181cd7de4f1f172e1966fb70cf0399d269edb3945

See more details on using hashes here.

Supported by

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