Skip to main content

EasyObs SDK: lightweight LLM/agent observability instrumentation via OpenTelemetry

Project description

easyobs-agent

Lightweight LLM/Agent observability SDK built on OpenTelemetry.

Install easyobs-agent in your agent service to send spans to the EasyObs console with minimal boilerplate.

Installation

pip install easyobs-agent

This installs all required dependencies including langchain-core, so LangChain auto-tracing works out of the box.

Quick Start

from easyobs_agent import init, traced, record_llm

# 1. Connect to EasyObs server
init(
    "http://127.0.0.1:8787",
    token="eobs_your_ingest_token",
    service="my-agent",
)

# 2. Decorate functions with @traced
@traced
def answer(question: str) -> str:
    result = call_llm(question)

    # 3. Record LLM metadata
    record_llm(model="gpt-4o-mini", tokens_in=120, tokens_out=80)
    return result

Features

Feature Description
init() Configure OTLP/HTTP exporter and connect to EasyObs
@traced Auto-create OTel span per function call (sync/async)
span_block() Context manager for child spans
span_tag() Attach attributes to the current span
record_llm() Record LLM call metadata (model, tokens, cost)
record_retrieval() Record RAG/retrieval results
record_tool() Record tool invocations
record_session() Attach session/user/request IDs
EasyObsCallbackHandler LangChain callback handler (auto-tracing)

Auto LangChain Tracing

from easyobs_agent import init

# auto=True enables both capture_io and auto_langchain
init(
    "http://127.0.0.1:8787",
    token="eobs_…",
    service="rag-bot",
    auto=True,
)

# All LangChain invocations are automatically captured — no callbacks needed
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o-mini")
llm.invoke("Hello")  # span created automatically

Advanced Usage

Selective I/O Capture

@traced(capture=True)   # force capture for this function only
def sensitive_fn(query: str) -> str: ...

@traced(capture=False)  # opt-out regardless of global setting
def secret_fn(api_key: str) -> str: ...

Manual Span Blocks

from easyobs_agent import span_block, record_retrieval

with span_block("search", kind="retrieve") as span:
    docs = vector_store.search(query)
    record_retrieval(query=query, docs=docs)

Requirements

  • Python >= 3.9
  • OpenTelemetry SDK >= 1.28.0
  • langchain-core >= 0.3.0

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

easyobs_agent-0.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

easyobs_agent-0.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for easyobs_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 306000f9419006efc3969bcd1992e62f16c00eee68dcad956eac2b499864c0e1
MD5 8489ba5d09befbb29e658d99b0ed381a
BLAKE2b-256 e55b02c5a48a4e980f3374d203695b49328144980c6db6b24ad40c9beee4cb7f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for easyobs_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f521f0d4382c8d8eeb1d19897bffa89e90fef4730c252a2b610b311d2b649008
MD5 880fc8deab56fb4e4d26a55121b8dfa9
BLAKE2b-256 3153d17bc562da114edc12fb3aa73d872c10db015be1c2eec91d86a872feb5e1

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