Skip to main content

Python Agent

This repository ships two related packages:

Package PyPI name Import Role
otel-python-sdk harness-sdk harness_sdk Generic OpenTelemetry-based instrumentation SDK (HTTP, gRPC, DB, GenAI, plugins).
Traceable agent traceable-agent traceableai Extends the SDK with Traceable blocking (libtraceable), remote config, and sampling. Depends on harness-sdk.

The SDK lives in otel-python-sdk/. The Traceable wrapper and native filter are under src/traceableai/.

Requirements: Python >= 3.10

Supported OS for libtraceable (blocking filter): Ubuntu 18.04+, CentOS 7+, Debian 10+, Amazon Linux 2+


Installation

Local development (both packages)

python3 -m venv venv
source venv/bin/activate

# Vendor GenAI instrumentation (needed for anthropic/openai tests and builds)
bash scripts/fetch-vendor.sh
python3 otel-python-sdk/scripts/bundle_vendor.py

# Editable SDK + Traceable agent
pip install -e "./otel-python-sdk[dev]"
pip install -r requirements.txt -r dev-requirements.txt
pip install -e .

Optional GenAI extras:

pip install -e "./otel-python-sdk[anthropic,openai,litellm]"

If grpc fails to compile, prepend: GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true

Production install

pip install harness-sdk          # SDK only
pip install traceable-agent          # SDK + Traceable (includes libtraceable on supported Linux)

Configuration

Configuration is layered: defaults → YAML file → environment variables. Use separate files for SDK vs Traceable-specific settings.

Setting Config file env Prefix Examples
SDK (instrumentation, reporting, GenAI, plugins) HA_CONFIG_FILE HA_* HA_SERVICE_NAME, HA_REPORTING_ENDPOINT, HA_CONTROL_PLUGINS
Traceable (blocking, remote config, sampling) TA_CONFIG_FILE TA_* TA_BLOCKING_CONFIG_ENABLED, TA_REMOTE_CONFIG_ENABLED

Legacy aliases AT_CONFIG_FILE / AT_* are still read for SDK settings during migration.

SDK config (HA_CONFIG_FILE)

Example agent-config.yaml:

service_name: my-service
enabled: true

reporting:
  endpoint: http://localhost:4318/v1/traces
  trace_reporter_type: OTLP   # or ZIPKIN
  secure: false
  token: ""

data_capture:
  http_headers:
    request: true
    response: true
  http_body:
    request: true
    response: true
  body_max_size_bytes: 131072

propagation_formats: ["TRACECONTEXT", "B3"]

gen_ai:
  enabled: true
  payload_capture_enabled: true
  payload_evaluation_enabled: true

plugins:
  control: []                # e.g. custom control plugins by name
  observability:
    - builtin_pipeline
    - builtin_span_attributes

Point the agent at the file:

export HA_CONFIG_FILE=/path/to/agent-config.yaml

Common environment overrides:

export HA_SERVICE_NAME=my-service
export HA_REPORTING_ENDPOINT=http://otel-collector:4318/v1/traces
export HA_REPORTING_TRACE_REPORTER_TYPE=OTLP
export HA_ENABLED=true
export HA_GEN_AI_ENABLED=true
export HA_CONTROL_PLUGINS=traceable   # comma-separated control plugin names
export HA_ENABLE_CONSOLE_SPAN_EXPORTER=true   # dev only: print spans to stdout

Traceable config (TA_CONFIG_FILE)

Example traceable-config.yaml:

blocking_config:
  enabled: true
  evaluate_body: true
  max_recursion_depth: 20

remote_config:
  enabled: true
  endpoint: localhost:5442
  poll_period_seconds: 30

sampling:
  enabled: false
export TA_CONFIG_FILE=/path/to/traceable-config.yaml
export TA_REMOTE_CONFIG_ENABLED=false    # disable remote config polling in dev/tests

For integration tests, see test/traceableai/agent/integration-agent-config.yaml and test/traceableai/agent/traceable-integration-config.yaml.


Usage

SDK only (harness_sdk)

Use when you want instrumentation and OTLP/ZIPKIN export without Traceable blocking or remote config.

Code-based instrumentation

from harness_sdk.agent import Agent

app = Flask(__name__)

agent = Agent()
agent.instrument(app)   # Flask + other supported libraries

Auto-instrumentation

export HA_CONFIG_FILE=/path/to/agent-config.yaml
harness-instrument flask run -p 5000

Traceable agent (traceableai)

Use for production Traceable deployments (blocking, remote config, libtraceable).

Code-based instrumentation

from traceableai.agent import Agent

app = Flask(__name__)

agent = Agent()
agent.instrument(app)

# Prefer plugins.control in HA_CONFIG_FILE; this remains for backward compatibility:
agent.add_traceable_filter()

Recommended: enable the Traceable control plugin via config instead of calling add_traceable_filter():

# agent-config.yaml (HA_CONFIG_FILE)
plugins:
  control:
    - traceable

Auto-instrumentation

export HA_CONFIG_FILE=/path/to/agent-config.yaml
export TA_CONFIG_FILE=/path/to/traceable-config.yaml
traceableai-instrument flask run -p 5000

traceableai-instrument loads sitecustomize, starts the agent, auto-instruments supported libraries, and registers the Traceable control plugin (unless deferred for gunicorn post-fork).


Developing

python3 -m venv venv
source venv/bin/activate
bash scripts/fetch-vendor.sh
python3 otel-python-sdk/scripts/bundle_vendor.py
pip install -e "./otel-python-sdk[dev,anthropic,openai,litellm]"
pip install -r requirements.txt -r dev-requirements.txt
pip install -e .

Testing

SDK unit tests (matches CI “SDK Unit Tests”):

./scripts/run-sdk-unit-tests.sh
# Full integration tests (mysql/postgres/docker):
RUN_SDK_INTEGRATION_TESTS=1 ./scripts/run-sdk-unit-tests.sh

Traceable unit tests (from repo root; skips native filter and duplicate instrumentation tree):

python3 -m pytest \
  --ignore=test/traceableai/agent/instrumentation

Integration services (optional):

cd test/externalServices && docker compose up -d

Building

pip install -r requirements.txt
python3 -m build
# Or all wheel variants:
# CIBW_SKIP="*37* *38* ..." ./build_artifacts.sh

Docker-based unit test image (legacy):

docker build -f docker/test_apps/unittest.Dockerfile -t pythonunittest .
docker run --rm pythonunittest

Updating libtraceable

  1. Update filter/libtraceable.h if the header changed.
  2. Edit ./src/download.py and bump LIBTRACEABLE_VERSION.
  3. Verify with a test app under docker/test_apps/.

Updating protos

git submodule update --init --recursive
./scripts/build_proto.sh

Metadata

Release files for traceable-agent 2.3.1

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

Source distribution (sdist)

Source distribution for traceable-agent 2.3.1
File Size Uploaded
traceable_agent-2.3.1.tar.gz 18.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for traceable-agent 2.3.1
File
traceable_agent-2.3.1-cp314-cp314-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 Linux musl 1.2+ x86-64 Details
traceable_agent-2.3.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details
traceable_agent-2.3.1-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
traceable_agent-2.3.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
traceable_agent-2.3.1-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
traceable_agent-2.3.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
traceable_agent-2.3.1-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
traceable_agent-2.3.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
traceable_agent-2.3.1-cp310-cp310-musllinux_1_2_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.2+ x86-64 Details
traceable_agent-2.3.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details

Total release size: 126.0 MB

Release files / traceable_agent-2.3.1.tar.gz

Download URL traceable_agent-2.3.1.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7e3c4050dd1e6bf2703dcedde6a97c094b93ba5b5791d17a6f84219aa530f930
BLAKE2b-256 checksum
How to use checksums
4c4f52672b8231f5373607ac20047c3536f451d54752a21c9bf494f4d0f1547b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.1-cp314-cp314-musllinux_1_2_x86_64.whl
Size 13.1 MB
Tags CPython 3.14 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
0c2ac4c68a53a184ad7477060ae3aaf1e781f85358d91c25ce8a3819529c81f6
BLAKE2b-256 checksum
How to use checksums
5762aa65b2053c44edb064385060504578ddef000f976f198a9c5d043530f821
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 12.1 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6f265f46a17e97132d8bf8ee5b33ec5c399e1bf967c30edfa59e10e457b17229
BLAKE2b-256 checksum
How to use checksums
27457be26d3c64b533a71ebb2a70b501d890f472cfb7348a2253970d186a9953
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.1-cp313-cp313-musllinux_1_2_x86_64.whl
Size 13.1 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
3494c5de1729f2220df65e2e5368bbce00cb4dc2b8d91a33f1db7e5019741261
BLAKE2b-256 checksum
How to use checksums
7530730ce07fe87a6f3d1ce074a7187a977889e9f14799565969a2a71058d272
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 12.1 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3fc42660face2e219b7d6c2dc94962bbce42a92e0c73b18c80b7254f93d75da8
BLAKE2b-256 checksum
How to use checksums
02f3f06e478e944c33db54bbbeaca76c24d8c524578324f5d1c0f2743de914a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.1-cp312-cp312-musllinux_1_2_x86_64.whl
Size 13.1 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
0182e73f30228a0437a50d7b1ac9c80838bb35d1ed777bb950fb4e0ea6702a26
BLAKE2b-256 checksum
How to use checksums
200bfbc420f3bb4ee53763d299c0abd4e2f8af6f80a725cf2f5d3b55e7f44d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 12.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ac9cde55ac71562695ad50b6cf37bc50c5bc413c95501b3943c0a57e11f88724
BLAKE2b-256 checksum
How to use checksums
bf4148378cf322fe88fb4270ba7a334cb6f164f8994901cf96c04db8086fef31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.1-cp311-cp311-musllinux_1_2_x86_64.whl
Size 13.1 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
0c314864a869460494ce2146f96fad45d5b2182a1195504bcb2288eb3aa63445
BLAKE2b-256 checksum
How to use checksums
bc0e60ab4195685b023e5e2fed5bcaff49b641d9d3c944af60e1f694efbf6055
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 12.1 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
82f452e994c0890ae1cab8833f4db466f326e855f7618811c2f7e6a96d51d142
BLAKE2b-256 checksum
How to use checksums
599fcce21f86e0e39c9afb3ee64b2f7fc70f2a62f2bcd9d6302c7ec2047d9f09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp310-cp310-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.1-cp310-cp310-musllinux_1_2_x86_64.whl
Size 13.1 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
742e083ba05c48c3c536562e2e80a388a45f9aa68182686313d0980f9de1c5af
BLAKE2b-256 checksum
How to use checksums
d5eeb2bd605a127173b29cf84024fd48894de3c1c0dc06e9ac42a4f9ea28f5ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / traceable_agent-2.3.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 12.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
0bc80768c27201547840f73b0b35d6dc82fa8e84b4b98b14f4f2d4f8b0433c64
BLAKE2b-256 checksum
How to use checksums
ab681aa5fc3554de93f437466d866bf8da239d15a5349bd8d57e4a16b57a9d8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

2.3.1 This release

11 release files

2.3.0

10 release files

2.0.1

13 release files

2.0.0

13 release files

1.3.1

9 release files

1.3.0

9 release files

1.2.3

11 release files

1.2.2

11 release files

1.2.0

11 release files

1.1.4

6 release files

1.1.3

6 release files

1.1.2

6 release files

1.1.1

6 release files

1.1.0

6 release files

1.0.4

6 release files

1.0.3

6 release files

1.0.2

6 release files

1.0.1

6 release files

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