Moduna Python SDK for tracing AI agent frameworks with Traceloop.
Project description
Moduna Python SDK
Moduna is a small Python SDK that brands and simplifies Traceloop setup for AI agent frameworks. It gives
applications a stable moduna import path, framework-aware instrumentation, and Moduna API-key resolution from
configuration, exported environment variables, or .env.
Installation
Install the SDK with all supported framework integrations:
uv add moduna
pip install moduna
The framework extras are also available for teams that prefer explicit dependency declarations:
uv add "moduna[langchain]"
pip install "moduna[langchain]"
uv add "moduna[crewai]"
pip install "moduna[crewai]"
Quick Start
from moduna import Instruments, Moduna
moduna = Moduna()
moduna.init(
{
"app_name": "customer support",
"framework": Instruments.LANGCHAIN,
"api_key": "mod_...",
}
)
Set a conversation ID using the Moduna-branded tracing namespace:
from moduna.sdk.tracing import set_conversation_id
set_conversation_id("customer-123")
Configuration
Moduna resolves the API key in this order:
api_keypassed toModuna().init(...)- exported
MODUNA_API_KEY MODUNA_API_KEY=...in a local.envfile
The production Moduna endpoint is used by default. For local development, create
an ignored config.toml in the project root to switch to a local collector:
[sdk]
base_url = "http://localhost:4318"
You can also override the endpoint per application:
from moduna import Instruments, Moduna
Moduna().init(
{
"app_name": "support-agent",
"framework": Instruments.LANGCHAIN,
"base_url": "http://localhost:4318",
}
)
Frameworks
LangChain
from langchain_core.prompts import ChatPromptTemplate
from moduna import Instruments, Moduna
from moduna.sdk.tracing import set_conversation_id
Moduna().init({"app_name": "langchain-app", "framework": Instruments.LANGCHAIN})
set_conversation_id("conversation-1")
prompt = ChatPromptTemplate.from_messages([("human", "{question}")])
CrewAI
from moduna import Instruments, Moduna
from moduna.sdk.tracing import set_conversation_id
Moduna().init({"app_name": "crewai-app", "framework": Instruments.CREWAI})
set_conversation_id("crew-run-1")
Moduna installs the Traceloop/OpenTelemetry CrewAI instrumentation. Install the CrewAI runtime separately in your application when you build CrewAI agents.
Development
Activate the local virtual environment before running checks:
source .venv/bin/activate
uv sync
uv run ruff format .
uv run ruff check .
uv run pytest
uv build
Use uv run ruff format --check . in CI when you want formatting verification without rewriting files.
Publishing
GitHub Actions validates pull requests and every push to main. A successful
main build publishes only when the version in pyproject.toml does not
already exist on PyPI.
Configure the PyPI token once:
- Open the GitHub repository.
- Go to Settings → Secrets and variables → Actions.
- Add a repository secret named
PYPI_TOKEN. - Paste the PyPI token value from your local
.env.
Never commit .env or the token.
Prepare a release with uv:
source .venv/bin/activate
uv version --bump patch
git add pyproject.toml uv.lock
git commit -m "Release Moduna $(uv version --short)"
git push origin main
Changes that do not bump the version still run the full CI pipeline and skip the PyPI upload successfully.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moduna-0.1.9.tar.gz.
File metadata
- Download URL: moduna-0.1.9.tar.gz
- Upload date:
- Size: 90.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0bf826d2181362f965f00d0e9b14090ea2d70cedae99781678ccae96bebf41a
|
|
| MD5 |
5000afd708d34e33ed091a59b14fe0e9
|
|
| BLAKE2b-256 |
f415df4b7ea26677ee042173f897c95c396d91758fd5565bd8ba6971843b18b3
|
File details
Details for the file moduna-0.1.9-py3-none-any.whl.
File metadata
- Download URL: moduna-0.1.9-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
075d0233ea9758b06742349797db0ac98a19f4b31985a69d9104f5fe86ca7466
|
|
| MD5 |
ce0c707cd05155ccad35dd0b2874bf81
|
|
| BLAKE2b-256 |
0255eb6593ac7ba2ccb90006851994ec0265e8c50a093bfe4c4612abe1f9ea15
|