Skip to main content

A Acuvity tracer that instruments the http calls

Project description

acutracer

A llm flow tracer

The following repo will have the instrumentors for a agentic system.

The instrumentor will trace all the outgoing calls made through a agentic system.

The following headers will be added to the calls.

X-acuvity-trace-id X-acuvity-span-id

The headers will be captured by the proxy for further processing.

Visualization of the traces

All the traces are OTEL compatible, so any OTEL collector can be used to view the traces locally.

Supported Instrumentors for python

  1. Web Frameworks:

    • FastAPIInstrumentor
    • FlaskInstrumentor
    • DjangoInstrumentor
  2. Databases:

    • MongoInstrumentor
  3. HTTP Clients:

    • RequestsInstrumentor
    • URLLibInstrumentor
    • AioHTTPClientInstrumentor

Future work for Instrumentors in python

  1. gRPC:

    • GRPCInstrumentor
  2. AWS:

    • BotoInstrumentor
  3. Logging:

    • LoggingInstrumentor

To use these instrumentors, you typically need to install the corresponding instrumentation package. For example:

pip install opentelemetry-instrumentation-<name>

Where <name> is the lowercase name of the library you want to instrument (e.g., flask, django, requests, etc.).

Usage example:

from opentelemetry.instrumentation.<name> import <Name>Instrumentor

<Name>Instrumentor().instrument()

Replace <name> and <Name> with the appropriate library name (e.g., flask and Flask).

Jaeger example with FAST API instrumentor:

Setting up the app:

1st pip install the acutracer

pip install acutracer

Import the following 3 lines.

from acutracer.instrumentors.python.fastapi.instrumentor import FastAPIAppInstrumentor

instrumentor = FastAPIAppInstrumentor()
tracer = instrumentor.instrument(app=app)

Setting Up and Using Jaeger UI (for macOS)

Starting Jaeger

Run the following command to start the Jaeger all-in-one Docker container:

docker run -d --name jaeger \
  -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
  -e COLLECTOR_OTLP_ENABLED=true \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 5778:5778 \
  -p 16686:16686 \
  -p 14317:4317 \
  -p 4318:4318 \
  -p 14250:14250 \
  -p 14268:14268 \
  -p 14269:14269 \
  -p 9411:9411 \
  jaegertracing/all-in-one:latest

Note: We've changed -p 4317:4317 to -p 14317:4317. This maps the container's internal port 4317 to the host's port 14317.

Accessing the Jaeger UI

Once the container is running, you can access the Jaeger UI by opening a web browser and navigating to:

http://localhost:16686

Viewing Traces

  1. Start your instrumented Python application.
  2. Make some requests to your application to generate traces.
  3. Open the Jaeger UI in your web browser.
  4. In the UI:
    • Select your service from the "Service" dropdown (it should be named after your Python application).
    • Set an appropriate time range.
    • Click "Find Traces" to view your traces.

Troubleshooting

If you don't see any traces:

  1. Check that your application is running and generating traffic.
  2. Ensure that the Jaeger agent port (6831) is accessible from your application.
  3. Verify that the exporter in your Python code is correctly configured to send traces to localhost:6831.
  4. Check the console output of your Python application for any error messages related to trace export.

Remember to stop the Jaeger container when you're done:

docker stop jaeger
docker rm jaeger

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

acutracer-0.1.1.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

acutracer-0.1.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file acutracer-0.1.1.tar.gz.

File metadata

  • Download URL: acutracer-0.1.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for acutracer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8429a2bca59a4e313374e008d3257f3a44cbd6ea3b44c6eb07e353ff927e2b89
MD5 fac629db9740bdb5e85f2810392200ee
BLAKE2b-256 2a5ac520305514c20db33d347ff87dc07724766f708e64db1d763a7ad97f5e9f

See more details on using hashes here.

File details

Details for the file acutracer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: acutracer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for acutracer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6dc37aea42116479e0aa70146cc403e078b97b2c5728bdee8675a634f4eadc59
MD5 c41e5f8fa7dd3fdc98a881ab9f6446a5
BLAKE2b-256 b691102562a901b5a2eb47559fba585f4b902a190c8349bc0e9f825486409169

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page