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.4.tar.gz (12.8 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.4-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.4-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.4-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.4-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.4-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.4.tar.gz.

File metadata

  • Download URL: traceable-agent-1.1.4.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for traceable-agent-1.1.4.tar.gz
Algorithm Hash digest
SHA256 9d5316ebf9c34ade4b5162b8bc32391613ae18cd8e055440ba8b1c5649f34b04
MD5 1a45b0b548e15392f4bb5c5d421d42ba
BLAKE2b-256 82d404da62d3d499a0f8f6fd8b7abbeeb6e6f321f1e66dc9dfaf5dc1731e446f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1afd136ef81aaf1d484b361138db3bec22532660e3cdd7995d5f9e4bbe137723
MD5 57c65ebac490a9cee8cc26f24d885b3f
BLAKE2b-256 85a572675c01545ee95526065c0f3428c980a677291dc458ddaa6719395235fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 daf7e0dab91f623f8d0b43f8f3c908e36a79dd50e04dfaeed5fc91cf0b86ec8a
MD5 02cecd2484e1bd654c5c30c242772443
BLAKE2b-256 69adbb74e62d459c6d3d79f55060ca859e629023802a4e3a1ba4fb94d4fb0c13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de29db2e50cefbfb7ec5bc8d594a3619cd3966ba382f8d9799bbe333fda03d57
MD5 8ed6571fc181df36bdc5a6eee08dcf8d
BLAKE2b-256 c5365bd3b7ebe5c58baf94df28fdf9da93eb14a9049cf5f2bfa8698ccdab031b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 806a173c893ef6b7b40897aa79c13bae4f68fba787905cd8531807d1afe17def
MD5 0b9cd17ff9d5c06bc66b002bbe7387c7
BLAKE2b-256 be4e53e5cced41eb20565cde63c47bdc876da2cff8f04a761f52075c0c9eb741

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61c441c0857a5a899f70bc15962b74faf59d4e22f34e1dab40042bbed58bb383
MD5 4953bd12de0a85247b17c664e3305ab0
BLAKE2b-256 ba1d5617c4cb9c6b0b142a710caae29f0b0a790598d7950aeb832a0e69b0badf

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