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.0.tar.gz (12.3 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.0-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.0-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.0-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.0-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.0-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.0.tar.gz.

File metadata

  • Download URL: traceable-agent-1.1.0.tar.gz
  • Upload date:
  • Size: 12.3 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.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable-agent-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1a7f8d9539aa784dec1d0cc20e998b40266f7aa63ed40da3ece4439218a06f49
MD5 818ceaea7ac73aea2faae28104cce199
BLAKE2b-256 9f60f11bdb52cc9396dd35b73f0d0a40665606ad648e9471a10aa6f0f1efd47e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceable_agent-1.1.0-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.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 65e34169d1318839a1bf5361aed2235e205a8aeac56d5c8488520f1632a9fba6
MD5 2e93e5c9f618d85b2a41e778628bf577
BLAKE2b-256 140cf424018b89f7cad0b59cf940b2ccd20f7c75ea0ac831fdb8f48015f575ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceable_agent-1.1.0-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.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fd72b722b0e25049cbb843fddd291d1fd0bde193c19f99ce71922df2d56b9020
MD5 c028de52dbc06a1916b231a79eefe45c
BLAKE2b-256 10eef109d0d1b5b7cdcf90a29ec70497d7e972a3110d7ec2ae3589126caef1d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceable_agent-1.1.0-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.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a581534368b79624fbe0402aed5a7658be39e7541bca861ea4c15baa71313c3b
MD5 2c4655d62fe93160f491a7cdf3549ba9
BLAKE2b-256 b74a21b7f92ad970c7af1db8bfcc03e8996b395cca3244d424b9647dbe128c2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceable_agent-1.1.0-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.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5475898dcbe26a1ccdfe314ac5de15162214463857f386c9e15a9904fc58739
MD5 29663e3693d13ade388db52f6d41b69f
BLAKE2b-256 5b481efcec41e045c2b3509be242f3ffaa985fcff9be6f688da1b96fd7cebac7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceable_agent-1.1.0-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.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for traceable_agent-1.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92ab87b0b69eb7729fde6f32aae7a1fbacf8f3079c6c53deed258b3925501fb9
MD5 022b5a24471a47df65bfadb807d73107
BLAKE2b-256 b4077a86ff1e82013f43e9377d24309802b444014588036727599e4dcf2fa41d

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