Skip to main content

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

License

MIT

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

uselemma_tracing-1.0.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

uselemma_tracing-1.0.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file uselemma_tracing-1.0.2.tar.gz.

File metadata

  • Download URL: uselemma_tracing-1.0.2.tar.gz
  • Upload date:
  • Size: 5.0 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

Hashes for uselemma_tracing-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ecc1a212d0400370d61047f65229e4e854c4470832a6931c0f0fe55bca0f9d02
MD5 2c9ff8117b371f4225005f1b0a5081f2
BLAKE2b-256 a3b887a01d0d87f755886c0d817e96d73329dc2828302d512b195e1d19913bd1

See more details on using hashes here.

File details

Details for the file uselemma_tracing-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: uselemma_tracing-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.9 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

Hashes for uselemma_tracing-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ef439456766d3ed689f6e097280e95ae3296695af5bfd9b46542957fe488d049
MD5 cc6fee1babec2198ccf99468c6f2cac4
BLAKE2b-256 300c313dcccfdb7a11e66f37c42f5a72f795667ae578043f1b468332d0a84ee2

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