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.0

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

Built distributions (wheels)

Table of built distributions (wheels) for traceable-agent 2.3.0
File
traceable_agent-2.3.0-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.0-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.0-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.0-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.0-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.0-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.0-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.0-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.0-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.0-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.0-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.0-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
bc997f1e34a30fa67a1daa3d3b3d896b310f511edb663bd363e0a85a009291ea
BLAKE2b-256 checksum
How to use checksums
97617a2ccf8def7fcff2696b8966a0046825346d932363b09dc3cc149d3b7084
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.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.0-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
db1174ecf2265f2c46e86c70dbab4ae34865c3c95285ad9ed9cbf6ed2b5624be
BLAKE2b-256 checksum
How to use checksums
c44fc75b09743585702ff8f727c9ca9afbd5769dec02769d8d5953f972d5e07e
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.0-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.0-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
2bfc4e7695ff565fa2e049236a41ef97b5c638687a1fd17b780d4af482cda628
BLAKE2b-256 checksum
How to use checksums
90cb7f01f016175e81cdcb9ac987b15eb9430e5dcc3b5217792751aa433c4cd5
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.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.0-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
2d85cf8254b83d6d54a6b121cb17e194ceec7f7b3a91db0ab321d462cc4dae28
BLAKE2b-256 checksum
How to use checksums
b5cb782dcb083f89a97651d817a211713f00236e947007acea5f508f9f11dc5c
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.0-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.0-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
56735ee0c6287204b8d241f3be1f71373aa4f7943c9593e14230b20e791b1fb6
BLAKE2b-256 checksum
How to use checksums
477e72b4b5c1b996972d7f50dc743d139088c89a4586543e292b80bf63adfe95
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.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.0-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
88b46deac03f23bd7189fd70a9a25f45f10750812bdf3d1682bc535fa979b01b
BLAKE2b-256 checksum
How to use checksums
dbb30fd5665f40757b97c5ac3cb323c9b6e8db8cddd3206a713ed22ff76ecb81
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.0-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.0-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
72ce8e373dcb7a675b1a444a08317ebf27d52d3fc9d21f42b3b860ef57aabef6
BLAKE2b-256 checksum
How to use checksums
c9f912b67cf73b5f503bacdd4ad5a6c0c39e520e1b20c9e7f13ffbbac862332d
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.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.0-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
d5b6cad70b0b1a543645a100a5850a82c05f4896d415589d92ec2dcb39e83a92
BLAKE2b-256 checksum
How to use checksums
8781be9ced26190d01208088660320eeb527de4017fd4b2233e8ef9a4c0220d0
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.0-cp310-cp310-musllinux_1_2_x86_64.whl

Download URL traceable_agent-2.3.0-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
7243566798ef57c29d9a5688f9e7edf83d5c649724d8af41a8f54cfef360756b
BLAKE2b-256 checksum
How to use checksums
9ab22b210e4f5cadee7fbc4fb222ea746bef45239f128b9704c491308d48c369
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.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL traceable_agent-2.3.0-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
d05f640e35391f6545daa67845a459dea0569f68c850548d2ebf9972d0ff7a38
BLAKE2b-256 checksum
How to use checksums
eb735a1e6ead645b639f504cccd557bd7cf77d736e8cb083aa1ed881881066d5
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.0 This release

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