Skip to main content

Atomic Lens Python SDK. OpenTelemetry-native auto-instrumentation for LLM agents.

Project description

atomiclens

OpenTelemetry-native observability for LLM agents. One init() call auto-instruments your OpenAI, Anthropic, and Hugging Face calls and exports priced, attributed spans (tokens, USD cost, latency, model) to any OTLP endpoint, including the open-source Atomic Lens backend and dashboard.

pip install atomiclens            # core
pip install "atomiclens[openai]"  # + OpenAI auto-instrumentation
pip install "atomiclens[all]"     # OpenAI + Anthropic + Hugging Face

Quickstart

import atomiclens

atomiclens.init(service_name="my-agent", otlp_endpoint="http://localhost:4318")

# Every OpenAI / Anthropic / Hugging Face call is now traced with token
# counts and USD cost, with no other code change.
from openai import OpenAI

client = OpenAI()
client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello"}],
)

Streaming calls are handled too: stream_options.include_usage is injected so token usage and cost are captured even when you stream.

Attribution

Tag spans with the workflow, agent, user, and team they belong to so the dashboard can break cost down by any of them:

from atomiclens import workflow, agent, set_user, set_team

set_user("user_123")
set_team("growth")

with workflow("weekly-report"):
    summarize()          # spans inherit workflow="weekly-report"

@agent("researcher")
def research(topic): ...  # spans inherit agent_name="researcher"

Configuration

init() reads sensible defaults from the environment so you can configure it without touching code:

Env var Purpose
ATOMICLENS_OTLP_ENDPOINT Where spans are exported (defaults to http://localhost:4318)
ATOMICLENS_API_KEY Sent as the ingest key to a protected backend

service_name is a required argument to init(). init() is idempotent, so calling it more than once is safe (pass force=True to reconfigure).

Framework integrations

LangChain and LlamaIndex callback handlers are available as optional extras (pip install "atomiclens[langchain]" / "atomiclens[llamaindex]").

License

Apache-2.0. Source and the full self-hostable backend + dashboard live at github.com/Worldwideblake/atomic-lens.

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

atomiclens-0.1.0.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

atomiclens-0.1.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file atomiclens-0.1.0.tar.gz.

File metadata

  • Download URL: atomiclens-0.1.0.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for atomiclens-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca21d8b7bba8d76e30d31f04b392415f01a0a4cf5a5c186e49cff7d7138342cc
MD5 5f13580b8a66651326ccdf71e93df9ff
BLAKE2b-256 dd83bb868ee78b99cafcc539c005772d525e34b1c1ea7145b64aaa66d6d2407d

See more details on using hashes here.

File details

Details for the file atomiclens-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: atomiclens-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for atomiclens-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1b278f5d1fa6cbd0ae81db646999a79fee4bf0e7992a340ddb9c27de7cdd80e
MD5 f79fbd91f560c216e7d302c047516cd7
BLAKE2b-256 38b3b9f34757fd59d737befdfca682a72ec0f89d09b0ad452ff98f09cf6dd947

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