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.2.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.2-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.2-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.2-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.2-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.2-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.2.tar.gz.

File metadata

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

File hashes

Hashes for traceable-agent-1.1.2.tar.gz
Algorithm Hash digest
SHA256 839ca12ebc3e680f5b22382d88ec2675e71d75c258fde44a8e15e810b3dceb96
MD5 11f182e670dd0b0d918b478ed120bd08
BLAKE2b-256 40d99ad3e7325d3b67118fd00dc664aeef5684d679c81bc079f25e11c96ed835

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4961e6fb0e76c6a73d0936405004650bfa305623d19026634921d9f8d26c68f0
MD5 7d6178ba0a6668e0f7a98d4cef8aa799
BLAKE2b-256 5634bb8f00ded800ceec62a902c53e53ddc24f802705decda24f6adfd35d82a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8b7d208af19644728c45dcbf72fec499080c9ae7f9ad12d82dd686d8e8f57aae
MD5 55e12db582fa5a2a1e18f5c9a907792e
BLAKE2b-256 89ced2f996ce81ecc2eefe89676a8d43beda49fc5f931d9b651e018fedf580d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 319f01bb107874b8b3bd93eebbc2ecb468ca803525b2d81995595e8a489ef098
MD5 5fbad073a92bf8b3e3019b57af4e2371
BLAKE2b-256 af2b4bc12fab104fd58301549f31491def1c8526e5e21c037f7ced685f64ec92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5e11aa7b5d01b36a7e85973697b923672cc594b83cc8ae7cfff2f16fd0b320c
MD5 2773b4b757277d809ebc32b9fcc2bb48
BLAKE2b-256 12f54466810abaf9801e41bedfe5be369d1756fd22f1521bc8e16dbf72734e3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 befdc61386ec70264897ff37248676066c294a4a40bfc37a584b8865ab2d805b
MD5 4f91b33dfb79dd41a966aaa649cc5382
BLAKE2b-256 34c70f1b49c413317fc78c6688bb916b51a0fdbb05d01b6bb6300e1b22177e50

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