Skip to main content

Cloud-first, decorator-based tracing SDK for LLM applications and multi-agent systems

Project description

Noveum Trace SDK

CI Release codecov PyPI version Python 3.8+ License: Apache 2.0

Simple, intuitive tracing SDK for LLM applications and multi-agent systems.

Noveum Trace provides an easy way to add observability to your LLM applications. With intuitive context managers, you can trace function calls, LLM interactions, agent workflows, and multi-agent coordination patterns.

โœจ Key Features

  • ๐ŸŽฏ Simple Context Manager API - Add tracing with intuitive with statements
  • ๐Ÿค– Multi-Agent Support - Built for multi-agent systems and workflows
  • โ˜๏ธ Cloud Integration - Send traces to Noveum platform or custom endpoints
  • ๐Ÿ”Œ Framework Agnostic - Works with any Python LLM framework
  • ๐Ÿš€ Zero Configuration - Works out of the box with sensible defaults
  • ๐Ÿ“Š Comprehensive Tracing - Capture function calls, LLM interactions, and agent workflows
  • ๐Ÿ”„ Flexible Integration - Context managers for granular control

๐Ÿš€ Quick Start

Installation

pip install noveum-trace

Basic Usage

import noveum_trace

# Initialize the SDK
noveum_trace.init(
    api_key="your-api-key",
    project="my-llm-app"
)

# Trace any operation using context managers
def process_document(document_id: str) -> dict:
    with noveum_trace.trace_operation("process_document") as span:
        # Your function logic here
        span.set_attribute("document_id", document_id)
        return {"status": "processed", "id": document_id}

# Trace LLM calls with automatic metadata capture
def call_openai(prompt: str) -> str:
    import openai
    client = openai.OpenAI()
    
    with noveum_trace.trace_llm_call(model="gpt-4", provider="openai") as span:
        response = client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": prompt}]
        )
        span.set_attributes({
            "llm.input_tokens": response.usage.prompt_tokens,
            "llm.output_tokens": response.usage.completion_tokens
        })
        return response.choices[0].message.content

๐Ÿ—๏ธ Architecture

noveum_trace/
โ”œโ”€โ”€ core/              # Core tracing primitives (Trace, Span, Context)
โ”œโ”€โ”€ context_managers/  # Context managers for inline tracing
โ”œโ”€โ”€ transport/         # HTTP transport and batch processing
โ”œโ”€โ”€ integrations/      # Framework integrations (LangChain, etc.)
โ”œโ”€โ”€ streaming/         # Streaming LLM support
โ”œโ”€โ”€ threads/           # Conversation thread management
โ””โ”€โ”€ utils/             # Utilities (exceptions, serialization, etc.)

๐Ÿ”ง Configuration

Environment Variables

export NOVEUM_API_KEY="your-api-key"
export NOVEUM_PROJECT="your-project-name"
export NOVEUM_ENVIRONMENT="production"

Programmatic Configuration

import noveum_trace

# Basic configuration
noveum_trace.init(
    api_key="your-api-key",
    project="my-project",
    environment="production"
)

# Advanced configuration with transport settings
noveum_trace.init(
    api_key="your-api-key",
    project="my-project",
    environment="production",
    transport_config={
        "batch_size": 50,
        "batch_timeout": 2.0,
        "retry_attempts": 3,
        "timeout": 30
    },
    tracing_config={
        "sample_rate": 1.0,
        "capture_errors": True,
        "capture_stack_traces": False
    }
)

๐Ÿ”„ Context Manager Usage

For scenarios with granular control:

import noveum_trace

def process_user_query(user_input: str) -> str:
    # Pre-processing (not traced)
    cleaned_input = user_input.strip().lower()

    # Trace just the LLM call
    with noveum_trace.trace_llm_call(model="gpt-4", provider="openai") as span:
        response = openai_client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": cleaned_input}]
        )

        # Add custom attributes
        span.set_attributes({
            "llm.input_tokens": response.usage.prompt_tokens,
            "llm.output_tokens": response.usage.completion_tokens
        })

    # Post-processing (not traced)
    return format_response(response.choices[0].message.content)

def multi_step_workflow(task: str) -> dict:
    results = {}

    # Trace agent operation
    with noveum_trace.trace_agent_operation(
        agent_type="planner",
        operation="task_planning"
    ) as span:
        plan = create_task_plan(task)
        span.set_attribute("plan.steps", len(plan.steps))
        results["plan"] = plan

    # Trace tool usage
    with noveum_trace.trace_operation("database_query") as span:
        data = query_database(plan.query)
        span.set_attributes({
            "query.results_count": len(data),
            "query.table": "tasks"
        })
        results["data"] = data

    return results

๐Ÿ”— LangChain Integration

Noveum Trace provides seamless integration with LangChain and LangGraph applications through a simple callback handler.

from noveum_trace.integrations import NoveumTraceCallbackHandler
from langchain_openai import ChatOpenAI

# Initialize Noveum Trace
import noveum_trace
noveum_trace.init(project="my-langchain-app", api_key="your-api-key")

# Create callback handler
handler = NoveumTraceCallbackHandler()

# Add to your LangChain components
llm = ChatOpenAI(callbacks=[handler])
response = llm.invoke("What is the capital of France?")

What Gets Traced

  • LLM Calls: Model, prompts, responses, token usage
  • Chains: Input/output flow, execution steps
  • Agents: Decision-making, tool usage, reasoning
  • Tools: Function calls, inputs, outputs
  • LangGraph Nodes: Graph execution, node transitions
  • Routing Decisions: Conditional routing logic and decisions

Advanced Features

The integration also supports:

  • Manual Trace Control for complex workflows
  • Custom Parent Relationships for explicit span hierarchies
  • LangGraph Routing Tracking for routing decisions

For complete details and examples, see the LangChain Integration Guide.

๐Ÿงต Thread Management

Track conversation threads and multi-turn interactions:

from noveum_trace import ThreadContext

# Create and manage conversation threads
with ThreadContext(name="customer_support") as thread:
    thread.add_message("user", "Hello, I need help with my order")

    # LLM response within thread context
    with noveum_trace.trace_llm_call(model="gpt-4") as span:
        response = llm_client.chat.completions.create(...)
        thread.add_message("assistant", response.choices[0].message.content)

๐ŸŒŠ Streaming Support

Trace streaming LLM responses with real-time metrics:

from noveum_trace import trace_streaming

def stream_openai_response(prompt: str):
    with trace_streaming(model="gpt-4", provider="openai") as manager:
        stream = openai_client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": prompt}],
            stream=True
        )

        for chunk in stream:
            if chunk.choices[0].delta.content:
                content = chunk.choices[0].delta.content
                manager.add_token(content)
                yield content

        # Streaming metrics are automatically captured

๐Ÿงช Testing

Run the test suite:

# Install development dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run with coverage
pytest --cov=noveum_trace --cov-report=html

# Run specific test categories
pytest -m llm
pytest -m agent

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/Noveum/noveum-trace.git
cd noveum-trace

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Run examples
python docs/examples/basic_usage.py

๐Ÿ“– Examples

Check out the examples directory for complete working examples:

๐Ÿš€ Advanced Usage

Manual Trace Creation

# Create traces manually for full control
client = noveum_trace.get_client()

with client.create_contextual_trace("custom_workflow") as trace:
    with client.create_contextual_span("step_1") as span1:
        # Step 1 implementation
        span1.set_attributes({"step": 1, "status": "completed"})

    with client.create_contextual_span("step_2") as span2:
        # Step 2 implementation
        span2.set_attributes({"step": 2, "status": "completed"})

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

๐Ÿ™‹โ€โ™€๏ธ Support


Built by the Noveum Team

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

noveum_trace-0.3.9.tar.gz (189.8 kB view details)

Uploaded Source

Built Distribution

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

noveum_trace-0.3.9-py3-none-any.whl (96.8 kB view details)

Uploaded Python 3

File details

Details for the file noveum_trace-0.3.9.tar.gz.

File metadata

  • Download URL: noveum_trace-0.3.9.tar.gz
  • Upload date:
  • Size: 189.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for noveum_trace-0.3.9.tar.gz
Algorithm Hash digest
SHA256 089303d44fc954f2f4eb5e0957e3c0b27c1a4fb66f5de8d2e265862e3ae09329
MD5 91ceeac81beb18b977eaa332f7e30388
BLAKE2b-256 eab07ef86ebf538ae36d2db101e488ecc590384005be3ae73e69c553eb389189

See more details on using hashes here.

Provenance

The following attestation bundles were made for noveum_trace-0.3.9.tar.gz:

Publisher: release.yml on Noveum/noveum-trace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file noveum_trace-0.3.9-py3-none-any.whl.

File metadata

  • Download URL: noveum_trace-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 96.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for noveum_trace-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8cb18bad03665044b9da93178450b2ef5df3b42fb621c1354504887d41f284d6
MD5 e093c59a21d0fea49fd8026da8384cc3
BLAKE2b-256 128a1af6b8ede63584b8f23c5131a35f5f34ef297fa9185a14f4edbc0a14d9c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for noveum_trace-0.3.9-py3-none-any.whl:

Publisher: release.yml on Noveum/noveum-trace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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