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 blocking.h > blocking.h.preprocessed

Then mv blocking.h.preprocessed ./src/traceableai/filter/blocking.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.0.4.tar.gz (12.0 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.0.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.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (36.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

traceable_agent-1.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (27.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

traceable_agent-1.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

traceable_agent-1.0.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.1 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: traceable-agent-1.0.4.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for traceable-agent-1.0.4.tar.gz
Algorithm Hash digest
SHA256 91416a2402307afd9b475365251887f2273f45dba618517f617e9ba95bbbd6df
MD5 6f1fd1872930e9aeea8b6850028feb0c
BLAKE2b-256 a862e754ddaf5634a87f54a6a8b4b1dd05790e5fd1a97953965f1ece9ec2dc15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cfb737fa1cb2ce8c1d10158eab4702cea981e8e76381a8893e4617c974e3fd4a
MD5 cd48dc5fb07196a6d2a58012780885f7
BLAKE2b-256 1b3928f3153de64b12255bdc825959c357c779202dea63ae772284a1d156c691

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e190aff31afe13db88b8ffd7c52c63e86eae20eab651b9856da2c5ea3804939a
MD5 f11611e9d37be93db4900d23bf0af8f3
BLAKE2b-256 a26d11486d4645bf6d55b7a422b05468cf7a2a1aad63bedab417a676218fd4f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 969b1fbc9e01b975c7267d88e8a50fd20a6fbf1e61ee3892a19aa8d5b875739e
MD5 9376dda499347620726526e07c13f1c8
BLAKE2b-256 e14731a9765bec7224b63a9bf3487a8563e4ea048212a1ef8fbbe9c0a021d5b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1fc6928c633a591aa0b3afa9171dba5f35921e4b033eb94afb2ba48f1f5403a0
MD5 96687ade42dc4f5b14ae2d0cf1fc5dd8
BLAKE2b-256 7337c58ef17d923b2f0b52429736731631b680c8972a0ea12e602ec7d092d26c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for traceable_agent-1.0.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fdd9b34a3e4cbc3ffde5adf22a1640ddf25294210bd60601ec3a264eaa5facc9
MD5 cc9adbe9cede6f357a9a7f1ea1e39f40
BLAKE2b-256 00a38368bd2d2478bca89075d03d7fc5073ee6cf9fd27812fae0f0651c062c36

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