Skip to main content

Traceable.ai Python Agent

Project description

Python Agent

Usage

Python traceable agent requires Python >= 3.6

Additionally, to use the traceable filter, you must be on a supported OS.

  • Ubuntu 18.04+
  • Centos 7+
  • Debian 10+
  • Amazon Linux 2+

Instrumentation methods

There are two ways to instrument your application, auto-instrumentation and code based instrumentation.

Autoinstrumentation

Simply prepend traceableai-instrument to your applications startup command.

ex: traceableai-instrument flask run

Code based instrumentation

Add the following snippet to your python apps entrypoint file:

from traceableai.agent import Agent

app = Flask(__name__)

agent = Agent()
agent.instrument(app) # This will instrument the flask app + any other modules that are supported
agent.add_traceable_filter() # add the traceable filter to enable blocking

Developing

# Create a virtual env & install dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt -r dev-requirements 

Note: if you run into an error installing grpc:

File "/Users/user/.pyenv/versions/3.9.4/lib/python3.9/distutils/unixccompiler.py", line 120, in _compile raise CompileError(msg) distutils.errors.CompileError: command '/usr/bin/clang' failed with exit code 1

prepend this env var to the above pip install command: GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true

Building

pip install -r requirements.txt
python3 -m build

Instrumenting

traceableai-instrument your_startup_command
# ex: traceableai-instrument flask run -p 5000 

Updating Libtraceable

When you want to update libtraceable you should first download the latest version and precompile the headers. gcc -E libtraceable.h > libtraceable.h.preprocessed

Then mv libtraceable.h.preprocessed ./src/traceableai/filter/libtraceable.h.preprocessed

Additionally, open src/download.py Edit the constant: LIBTRACEABLE_VERSION set it equal to the version you just generated headers for.

You can test this functionality by using the project within the: docker/test_apps It will fail to build if libtraceable cannot be downloaded

Updating the Proto

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

Unit Tests

build_artifacts.sh builds all the whl files. Specify skipped versions in (CIBW_SKIP) to only build 3.6 for unit tests.

CIBW_SKIP="*37* *38* *39* *310*" ./build_artifacts.sh
docker build --build-arg ARTIFACTORY_USER --build-arg ARTIFACTORY_TOKEN -f docker/test_apps/Dockerfile.unittest -t pythonunittest . && docker run --rm pythonunittest

Test applications

Refer to docker/test_apps/ and the corresponding scripts in scripts/

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

traceable-agent-1.1.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distributions

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

traceable_agent-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (45.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

traceable_agent-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (36.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

traceable_agent-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (27.4 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

traceable_agent-1.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

traceable_agent-1.1.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.2 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

Details for the file traceable-agent-1.1.1.tar.gz.

File metadata

  • Download URL: traceable-agent-1.1.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable-agent-1.1.1.tar.gz
Algorithm Hash digest
SHA256 d13d399c7ed8565344950f727b418d1e388974c6e1cd48b8fc5428ee9e82a865
MD5 a662ece52e5fd85a54af72c9b9a10af6
BLAKE2b-256 769d465152476cb8f4564ce79814af94bd488c1a2ac4be5c9b78a9a79feb5169

See more details on using hashes here.

File details

Details for the file traceable_agent-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: traceable_agent-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 45.6 MB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f0665bf6f6eb0be8cb985df4c0aceaa5e41d60041fd9b175e40f1bbc94222499
MD5 6fc3fa38506b7b9495425d263fd43447
BLAKE2b-256 b80c87962dfd455e486e7f16455e4a6c10e8829fa9f98869fb6d09b84b0d67e9

See more details on using hashes here.

File details

Details for the file traceable_agent-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: traceable_agent-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 36.5 MB
  • Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6bba1fe0428279bda247a6a4f89cf2e6c60240b89521ecef946ca3d9081d1844
MD5 eb4899ff1889f1033c91031ee3571fa9
BLAKE2b-256 34890332465df089428cb057d24c967aa1ac266c19e02cd4558b8f6c975728e4

See more details on using hashes here.

File details

Details for the file traceable_agent-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: traceable_agent-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 27.4 MB
  • Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0847d313679d8ba4366509562df25078d064c839fbd74078d303ebd7d9855a17
MD5 68e77df6c4284128b52b24a380d41970
BLAKE2b-256 a032be4869ccbae40b4b146e95e887efa3159e0e1ed30a0c4b769cf5c33e4578

See more details on using hashes here.

File details

Details for the file traceable_agent-1.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: traceable_agent-1.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 18.3 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2fed2586aef06ae57effe7fd4452618a52c9d58c223079ce7b8c9bc213126930
MD5 8f6e0803f7d3290e47fefced8f563dbc
BLAKE2b-256 570dbfcab9a2294c044ac9bbc5595a7339ba69debdbe970d4bb16ce4663a8225

See more details on using hashes here.

File details

Details for the file traceable_agent-1.1.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: traceable_agent-1.1.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.2 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 64785019dad93f72b690d52f741882cdcfcd777a84b7c3a512747d725fd35b9c
MD5 6660f43a021ef4c26eff620784407b41
BLAKE2b-256 7ab11439352a1aa4704c70996e4157e919c0fc0fb87657ed2fa1248594668daa

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