| Name | iudex JSON |
| Version |
0.15.4
JSON |
| download |
| home_page | None |
| Summary | None |
| upload_time | 2024-10-20 18:45:32 |
| maintainer | None |
| docs_url | None |
| author | Drake Wong |
| requires_python | !=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9 |
| license | None |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Iudex
Next generation observability.
### Supported Libraries
✅ logger
✅ loguru
✅ sqlalchemy
✅ supabase
✅ modal
✅ streamlit
[Supported libraries from OTel](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/README.md):
✅ aio-pika
✅ aiohttp-client
✅ aiohttp-server
✅ aiopg
✅ asgi
✅ asyncio
✅ asyncpg
✅ aws-lambda
✅ boto
✅ boto3sqs
✅ botocore
✅ cassandra
✅ celery
✅ confluent-kafka
✅ dbapi
✅ django
✅ elasticsearch
✅ falcon
✅ fastapi
✅ flask
✅ grpc
✅ httpx
✅ jinja2
✅ kafka-python
✅ logging
✅ mysql
✅ mysqlclient
✅ pika
✅ psycopg
✅ psycopg2
✅ pymemcache
✅ pymongo
✅ pymysql
✅ pyramid
✅ redis
✅ remoulade
✅ requests
✅ sklearn
✅ sqlalchemy
✅ sqlite3
✅ starlette
✅ system-metrics
✅ threading
✅ tornado
✅ tortoiseorm
✅ urllib
✅ urllib3
✅ wsgi
[Supported libraries from OpenLLMetry](https://github.com/traceloop/openllmetry?tab=readme-ov-file#-what-do-we-instrument):
✅ OpenAI / Azure OpenAI
✅ Anthropic
✅ Cohere
✅ Ollama
✅ Mistral AI
✅ HuggingFace
✅ Bedrock (AWS)
✅ Replicate
✅ Vertex AI (GCP)
✅ Google Generative AI (Gemini)
✅ IBM Watsonx AI
✅ Together AI
✅ Aleph Alpha
✅ Chroma
✅ Pinecone
✅ Qdrant
✅ Weaviate
✅ Milvus
✅ Marqo
✅ LangChain
✅ LlamaIndex
✅ Haystack
✅ LiteLLM
### Table of contents
- [Iudex](#iudex)
- [Supported Libraries](#supported-libraries)
- [Table of contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Autoinstrumentation (Most Common)](#autoinstrumentation-most-common)
- [Log Attributes](#log-attributes)
- [Trace Span Attributes](#trace-span-attributes)
- [Integrations](#integrations)
- [Django](#django)
- [Modal](#modal)
- [Streamlit](#streamlit)
- [Using a main function](#using-a-main-function)
- [Tracing Your Functions](#tracing-your-functions)
- [Slack Alerts](#slack-alerts)
# Getting Started
Instrumenting your Python code with Iudex just takes a few steps.
1. Install dependencies.
```bash
pip install iudex
```
2. Follow the below instructions for your frameworks or use autoinstrumentation.
3. Make sure your app has access to the environment variable `IUDEX_API_KEY`. You can manually add this to `instrument` as well if you use something like a secrets manager.
4. You should be all set! Go to [https://app.iudex.ai/](https://app.iudex.ai/) and enter your API key.
5. Go to [https://app.iudex.ai/logs](https://app.iudex.ai/logs) and press `Search` to view your logs.
### Autoinstrumentation (Most Common)
Add this code to the VERY TOP of your entrypoint file, before all imports.
```python
from iudex import instrument
instrument(
service_name="YOUR_SERVICE_NAME", # highly encouraged
env="prod", # dev, local, etc
iudex_api_key="WRITE_ONLY_IUDEX_KEY", # only ever commit your WRITE ONLY key
)
# ^ Must run above all imports
```
Iudex auto-instrumentation must run before imports in order to patch libraries with specialized, no-overhead instrumentation code.
You should be all set! Iudex will now record logs and trace the entire life cycle for each request.
Go to [https://app.iudex.ai/](https://app.iudex.ai/) to start viewing your logs and traces!
### Log Attributes
You can add custom attributes to your logs by passing a dictionary to the `extra` parameter of the logging functions.
```python
logger.info("Hello Iudex!", extra={"my_custom_attribute": "my_custom_value"})
```
These attributes will be searchable and displayed on your logs in the Iudex dashboard.
### Trace Span Attributes
You can add custom attributes to the current trace span (if one exists) as follows:
```python
from iudex import set_attribute
# ... inside some function/span
set_attribute(key="my_custom_attribute", value="my_custom_value")
# ... rest of function
```
These attributes will be searchable and displayed on your trace spans in the Iudex dashboard.
# Integrations
Some frameworks are auto-instrumented through different entrypoints.
Find your framework below and follow the instructions to get set up.
(If it's not listed, the above section will work just fine!)
### Django
Add the following code to your `manage.py` file in the `main` function entrypoint.
```python
from iudex import instrument
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
instrument()
# ...
```
### Modal
Because Modal only loads libraries after running a particular serverless function, you need follow [their suggestions for using packages](https://modal.com/docs/guide/custom-container#add-python-packages-with-pip_install).
For example:
```python
@app.function(image=image, secrets=[modal.Secret.from_name("iudex-api-key")])
def square(x):
import logging
from iudex import instrument
instrument(service_name="test-modal-instrumentation", env="development")
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.info("This log shows up on Iudex!")
return x**2
```
### Streamlit
Streamlit works by running a static Python script which means all you need to do is encapsulate the scripts contents.
1. Import `iudex` and call `instrument()` to the top of your Streamlit app file.
2. Add `start_trace` and `end_trace` to the top and bottom of the file, respectively.
```python
from iudex import instrument, start_trace, end_trace, trace
instrument(
service_name="YOUR_SERVICE_NAME", # highly encouraged
env="prod", # dev, local, etc
iudex_api_key="WRITE_ONLY_IUDEX_KEY", # only ever commit your WRITE ONLY key
)
# ^ Must run above all imports
import streamlit as st
# call start_trace before your Streamlit app logic
token = start_trace(name="streamlit-app")
# your Streamlit app logic...
def generate_text(topic: str, mood: str = "", style: str = ""):
pass
end_trace(token)
# bottom of the file
```
3. Add the `trace` decorator to functions that you want to track. This will show the function and its arguments in the stacktrace.
```python
@trace
def generate_text(topic: str, mood: str = "", style: str = ""):
...
```
#### Using a main function
If your entire Streamlit app runs a single function, then the setup is a bit easier.
1. Import `iudex` and call `instrument()` to the top of your Streamlit app file.
2. Add the `trace` decorator to the main function.
```python
from iudex import instrument, trace
instrument(
service_name="YOUR_SERVICE_NAME", # highly encouraged
env="prod", # dev, local, etc
iudex_api_key="WRITE_ONLY_IUDEX_KEY", # only ever commit your WRITE ONLY key
)
# ^ Must run above all imports
import streamlit as st
@trace
def main():
# your Streamlit app logic...
main()
```
3. We still recommend adding the `trace` decorator to various functions.
### Tracing Your Functions
Iudex automatically traces framework and library functions.
For instance, if you use a framework like FastAPI or Django, Iudex will record subsequent library calls, durations, and metadata throughout the lifecycle of each request.
That said, you can also get more granular and trace your own functions.
A good heuristic for "when should I trace my own function" is whenever it might be helpful to see the function's stack trace.
Note: You must call `iudex.instrument()` earlier in your code (per above) before the traced function is invoked.
```python
from iudex import instrument, trace
instrument(
service_name="YOUR_SERVICE_NAME", # highly encouraged
env="prod", # dev, local, etc
iudex_api_key="WRITE_ONLY_IUDEX_KEY", # only ever commit your WRITE ONLY key
)
# ^ Must run above all imports
@trace
def my_function(arg1, arg2):
pass
```
# Slack Alerts
You can easily configure Slack alerts on a per-log basis.
First visit [https://app.iudex.ai/logs](https://app.iudex.ai/logs) and click on the `Add to Slack` button in the top right.
Once installed to your workspace, tag your logs with the `iudex.slack_channel_id` attribute.
```python
logger.info("Hello from Slack!", extra={"iudex.slack_channel_id": "YOUR_SLACK_CHANNEL_ID"})
```
Your channel ID can be found by clicking the name of the channel in the top left, then at the bottom of the dialog that pops up.
As long as the channel is public or you've invited the Iudex app, logs will be sent as messages to their tagged channel any time they are logged.
Raw data
{
"_id": null,
"home_page": null,
"name": "iudex",
"maintainer": null,
"docs_url": null,
"requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Drake Wong",
"author_email": "drake@iudex.ai",
"download_url": "https://files.pythonhosted.org/packages/e3/b0/73483b62d1f36ffff319e0c1f087bc2bd6fc3deaf6078a4a9234c3031b40/iudex-0.15.4.tar.gz",
"platform": null,
"description": "# Iudex\n\nNext generation observability.\n\n\n### Supported Libraries\n\n\u2705 logger\n\u2705 loguru\n\u2705 sqlalchemy\n\u2705 supabase\n\u2705 modal\n\u2705 streamlit\n\n[Supported libraries from OTel](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/README.md):\n\n\u2705 aio-pika\n\u2705 aiohttp-client\n\u2705 aiohttp-server\n\u2705 aiopg\n\u2705 asgi\n\u2705 asyncio\n\u2705 asyncpg\n\u2705 aws-lambda\n\u2705 boto\n\u2705 boto3sqs\n\u2705 botocore\n\u2705 cassandra\n\u2705 celery\n\u2705 confluent-kafka\n\u2705 dbapi\n\u2705 django\n\u2705 elasticsearch\n\u2705 falcon\n\u2705 fastapi\n\u2705 flask\n\u2705 grpc\n\u2705 httpx\n\u2705 jinja2\n\u2705 kafka-python\n\u2705 logging\n\u2705 mysql\n\u2705 mysqlclient\n\u2705 pika\n\u2705 psycopg\n\u2705 psycopg2\n\u2705 pymemcache\n\u2705 pymongo\n\u2705 pymysql\n\u2705 pyramid\n\u2705 redis\n\u2705 remoulade\n\u2705 requests\n\u2705 sklearn\n\u2705 sqlalchemy\n\u2705 sqlite3\n\u2705 starlette\n\u2705 system-metrics\n\u2705 threading\n\u2705 tornado\n\u2705 tortoiseorm\n\u2705 urllib\n\u2705 urllib3\n\u2705 wsgi\n\n[Supported libraries from OpenLLMetry](https://github.com/traceloop/openllmetry?tab=readme-ov-file#-what-do-we-instrument):\n\n\u2705 OpenAI / Azure OpenAI\n\u2705 Anthropic\n\u2705 Cohere\n\u2705 Ollama\n\u2705 Mistral AI\n\u2705 HuggingFace\n\u2705 Bedrock (AWS)\n\u2705 Replicate\n\u2705 Vertex AI (GCP)\n\u2705 Google Generative AI (Gemini)\n\u2705 IBM Watsonx AI\n\u2705 Together AI\n\u2705 Aleph Alpha\n\u2705 Chroma\n\u2705 Pinecone\n\u2705 Qdrant\n\u2705 Weaviate\n\u2705 Milvus\n\u2705 Marqo\n\u2705 LangChain\n\u2705 LlamaIndex\n\u2705 Haystack\n\u2705 LiteLLM\n\n\n### Table of contents\n- [Iudex](#iudex)\n - [Supported Libraries](#supported-libraries)\n - [Table of contents](#table-of-contents)\n- [Getting Started](#getting-started)\n - [Autoinstrumentation (Most Common)](#autoinstrumentation-most-common)\n - [Log Attributes](#log-attributes)\n - [Trace Span Attributes](#trace-span-attributes)\n- [Integrations](#integrations)\n - [Django](#django)\n - [Modal](#modal)\n - [Streamlit](#streamlit)\n - [Using a main function](#using-a-main-function)\n - [Tracing Your Functions](#tracing-your-functions)\n- [Slack Alerts](#slack-alerts)\n\n\n# Getting Started\nInstrumenting your Python code with Iudex just takes a few steps.\n\n1. Install dependencies.\n```bash\npip install iudex\n```\n2. Follow the below instructions for your frameworks or use autoinstrumentation.\n3. Make sure your app has access to the environment variable `IUDEX_API_KEY`. You can manually add this to `instrument` as well if you use something like a secrets manager.\n4. You should be all set! Go to [https://app.iudex.ai/](https://app.iudex.ai/) and enter your API key.\n5. Go to [https://app.iudex.ai/logs](https://app.iudex.ai/logs) and press `Search` to view your logs.\n\n\n### Autoinstrumentation (Most Common)\n\nAdd this code to the VERY TOP of your entrypoint file, before all imports.\n\n```python\nfrom iudex import instrument\ninstrument(\n service_name=\"YOUR_SERVICE_NAME\", # highly encouraged\n env=\"prod\", # dev, local, etc\n iudex_api_key=\"WRITE_ONLY_IUDEX_KEY\", # only ever commit your WRITE ONLY key\n)\n# ^ Must run above all imports\n```\n\nIudex auto-instrumentation must run before imports in order to patch libraries with specialized, no-overhead instrumentation code.\n\nYou should be all set! Iudex will now record logs and trace the entire life cycle for each request.\n\nGo to [https://app.iudex.ai/](https://app.iudex.ai/) to start viewing your logs and traces!\n\n### Log Attributes\n\nYou can add custom attributes to your logs by passing a dictionary to the `extra` parameter of the logging functions.\n\n```python\nlogger.info(\"Hello Iudex!\", extra={\"my_custom_attribute\": \"my_custom_value\"})\n```\n\nThese attributes will be searchable and displayed on your logs in the Iudex dashboard.\n\n### Trace Span Attributes\nYou can add custom attributes to the current trace span (if one exists) as follows:\n\n```python\nfrom iudex import set_attribute\n# ... inside some function/span\nset_attribute(key=\"my_custom_attribute\", value=\"my_custom_value\")\n# ... rest of function\n```\n\nThese attributes will be searchable and displayed on your trace spans in the Iudex dashboard.\n\n# Integrations\n\nSome frameworks are auto-instrumented through different entrypoints.\nFind your framework below and follow the instructions to get set up.\n(If it's not listed, the above section will work just fine!)\n\n### Django\n\nAdd the following code to your `manage.py` file in the `main` function entrypoint.\n\n```python\nfrom iudex import instrument\n\ndef main():\n \"\"\"Run administrative tasks.\"\"\"\n os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')\n\n instrument()\n\n # ...\n```\n\n### Modal\nBecause Modal only loads libraries after running a particular serverless function, you need follow [their suggestions for using packages](https://modal.com/docs/guide/custom-container#add-python-packages-with-pip_install).\n\nFor example:\n```python\n@app.function(image=image, secrets=[modal.Secret.from_name(\"iudex-api-key\")])\ndef square(x):\n import logging\n from iudex import instrument\n\n instrument(service_name=\"test-modal-instrumentation\", env=\"development\")\n\n logging.basicConfig(level=logging.INFO)\n logger = logging.getLogger(__name__)\n\n logger.info(\"This log shows up on Iudex!\")\n return x**2\n```\n\n### Streamlit\nStreamlit works by running a static Python script which means all you need to do is encapsulate the scripts contents.\n\n1. Import `iudex` and call `instrument()` to the top of your Streamlit app file. \n2. Add `start_trace` and `end_trace` to the top and bottom of the file, respectively.\n\n```python\nfrom iudex import instrument, start_trace, end_trace, trace\ninstrument(\n service_name=\"YOUR_SERVICE_NAME\", # highly encouraged\n env=\"prod\", # dev, local, etc\n iudex_api_key=\"WRITE_ONLY_IUDEX_KEY\", # only ever commit your WRITE ONLY key\n)\n# ^ Must run above all imports\nimport streamlit as st\n\n# call start_trace before your Streamlit app logic\ntoken = start_trace(name=\"streamlit-app\")\n\n# your Streamlit app logic...\ndef generate_text(topic: str, mood: str = \"\", style: str = \"\"):\n pass\n\nend_trace(token)\n# bottom of the file\n```\n3. Add the `trace` decorator to functions that you want to track. This will show the function and its arguments in the stacktrace.\n```python\n@trace\ndef generate_text(topic: str, mood: str = \"\", style: str = \"\"):\n ...\n```\n\n#### Using a main function\nIf your entire Streamlit app runs a single function, then the setup is a bit easier.\n\n1. Import `iudex` and call `instrument()` to the top of your Streamlit app file. \n2. Add the `trace` decorator to the main function.\n```python\nfrom iudex import instrument, trace\ninstrument(\n service_name=\"YOUR_SERVICE_NAME\", # highly encouraged\n env=\"prod\", # dev, local, etc\n iudex_api_key=\"WRITE_ONLY_IUDEX_KEY\", # only ever commit your WRITE ONLY key\n)\n\n# ^ Must run above all imports\nimport streamlit as st\n\n@trace\ndef main():\n # your Streamlit app logic...\n\nmain()\n```\n3. We still recommend adding the `trace` decorator to various functions.\n\n\n### Tracing Your Functions\nIudex automatically traces framework and library functions.\nFor instance, if you use a framework like FastAPI or Django, Iudex will record subsequent library calls, durations, and metadata throughout the lifecycle of each request.\n\nThat said, you can also get more granular and trace your own functions.\nA good heuristic for \"when should I trace my own function\" is whenever it might be helpful to see the function's stack trace.\n\nNote: You must call `iudex.instrument()` earlier in your code (per above) before the traced function is invoked.\n\n```python\nfrom iudex import instrument, trace\ninstrument(\n service_name=\"YOUR_SERVICE_NAME\", # highly encouraged\n env=\"prod\", # dev, local, etc\n iudex_api_key=\"WRITE_ONLY_IUDEX_KEY\", # only ever commit your WRITE ONLY key\n)\n# ^ Must run above all imports\n\n@trace\ndef my_function(arg1, arg2):\n pass\n```\n\n# Slack Alerts\nYou can easily configure Slack alerts on a per-log basis.\n\nFirst visit [https://app.iudex.ai/logs](https://app.iudex.ai/logs) and click on the `Add to Slack` button in the top right.\n\nOnce installed to your workspace, tag your logs with the `iudex.slack_channel_id` attribute.\n```python\nlogger.info(\"Hello from Slack!\", extra={\"iudex.slack_channel_id\": \"YOUR_SLACK_CHANNEL_ID\"})\n```\nYour channel ID can be found by clicking the name of the channel in the top left, then at the bottom of the dialog that pops up.\n\nAs long as the channel is public or you've invited the Iudex app, logs will be sent as messages to their tagged channel any time they are logged.\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.15.4",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "094ec9c64bf2888183413ef9755ae2bab0a4eb6d7e5581e8ed0590b57885c56a",
"md5": "f83154f458a032232f942a291389579f",
"sha256": "44743132943b025c0b6f5f8500851e6aa142148278a985edd2c53ce7d1df9626"
},
"downloads": -1,
"filename": "iudex-0.15.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f83154f458a032232f942a291389579f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
"size": 46869,
"upload_time": "2024-10-20T18:45:30",
"upload_time_iso_8601": "2024-10-20T18:45:30.501279Z",
"url": "https://files.pythonhosted.org/packages/09/4e/c9c64bf2888183413ef9755ae2bab0a4eb6d7e5581e8ed0590b57885c56a/iudex-0.15.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e3b073483b62d1f36ffff319e0c1f087bc2bd6fc3deaf6078a4a9234c3031b40",
"md5": "64b4c9c367c04e17ed2ff3658d0eb30b",
"sha256": "bb45fb1b7da74b703b5598ecc484446ad4ebda297ebfe149fbb07840e290932a"
},
"downloads": -1,
"filename": "iudex-0.15.4.tar.gz",
"has_sig": false,
"md5_digest": "64b4c9c367c04e17ed2ff3658d0eb30b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
"size": 37649,
"upload_time": "2024-10-20T18:45:32",
"upload_time_iso_8601": "2024-10-20T18:45:32.549881Z",
"url": "https://files.pythonhosted.org/packages/e3/b0/73483b62d1f36ffff319e0c1f087bc2bd6fc3deaf6078a4a9234c3031b40/iudex-0.15.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-20 18:45:32",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "iudex"
}