OpenTelemetry-based tracing module for Lemma
Project description
uselemma-tracing
OpenTelemetry-based tracing for AI agents. Capture inputs, outputs, timing, token usage, and errors — then view everything in Lemma.
Installation
pip install uselemma-tracing
Quick Start
1. Register the tracer provider
Call register_otel once when your application starts. It reads LEMMA_API_KEY and LEMMA_PROJECT_ID from environment variables by default.
from uselemma_tracing import register_otel
register_otel()
2. Wrap your agent
wrap_agent creates an OpenTelemetry span around your agent function and provides helpers for recording results.
from uselemma_tracing import TraceContext, wrap_agent
def my_agent(ctx: TraceContext, user_message: str):
result = do_work(user_message)
ctx.record_generation_results({"response": result})
return result
wrapped = wrap_agent("my-agent", my_agent, initial_state={"user_message": user_message})
result, run_id, span = wrapped()
Environment Variables
| Variable | Description |
|---|---|
LEMMA_API_KEY |
Your Lemma API key |
LEMMA_PROJECT_ID |
Your Lemma project ID |
Both are required unless passed explicitly to register_otel().
Documentation
- Tracing Overview — concepts, API reference, and usage patterns
License
MIT
Project details
Release history Release notifications | RSS feed
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 uselemma_tracing-2.0.0.tar.gz.
File metadata
- Download URL: uselemma_tracing-2.0.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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 |
8242b1760106290e2561ed62b24bc28811a4eda5879a6225ecb46678a76e5ae9
|
|
| MD5 |
5c8c3598cfb2ec54a39f55b702c8c3c7
|
|
| BLAKE2b-256 |
13b1e5e92f4cd829a21c7792f10c7060b0615c28a7a2f08ecce0165436101681
|
File details
Details for the file uselemma_tracing-2.0.0-py3-none-any.whl.
File metadata
- Download URL: uselemma_tracing-2.0.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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 |
cb3761b83d3300e472cd3565450704c40de8474d72300cc9c425535be04486ed
|
|
| MD5 |
dd67ff23a83732545372859199913b3c
|
|
| BLAKE2b-256 |
5389e3babefd0fb4bd3add9ff624ee5e57fc469fbfa138b63beb8fe81fa13828
|