Skip to main content

Moduna Python SDK for tracing AI agent frameworks with Traceloop.

Project description

Moduna Python SDK

PyPI version Python versions Package status License GitHub release Upload Python Package Downloads

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:

  1. api_key passed to Moduna().init(...)
  2. exported MODUNA_API_KEY
  3. MODUNA_API_KEY=... in a local .env file

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:

  1. Open the GitHub repository.
  2. Go to Settings → Secrets and variables → Actions.
  3. Add a repository secret named PYPI_TOKEN.
  4. 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

moduna-0.1.9.tar.gz (90.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moduna-0.1.9-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

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

Hashes for moduna-0.1.9.tar.gz
Algorithm Hash digest
SHA256 d0bf826d2181362f965f00d0e9b14090ea2d70cedae99781678ccae96bebf41a
MD5 5000afd708d34e33ed091a59b14fe0e9
BLAKE2b-256 f415df4b7ea26677ee042173f897c95c396d91758fd5565bd8ba6971843b18b3

See more details on using hashes here.

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

Hashes for moduna-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 075d0233ea9758b06742349797db0ac98a19f4b31985a69d9104f5fe86ca7466
MD5 ce0c707cd05155ccad35dd0b2874bf81
BLAKE2b-256 0255eb6593ac7ba2ccb90006851994ec0265e8c50a093bfe4c4612abe1f9ea15

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