Skip to main content

High-performance LLM tracing SDK with OpenTelemetry compliance and real-time evaluation

Project description

Noveum Trace SDK

Production-ready Python SDK for tracing LLM applications, multi-agent systems, and tool calls with OpenTelemetry compliance.

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

๐Ÿš€ Quick Start

import noveum_trace

# Initialize with your project ID
noveum_trace.init(project_id="my-ai-project")

# Use the simple @trace decorator
@noveum_trace.trace
def process_data(data):
    return f"Processed: {data}"

@noveum_trace.trace(type="llm", model="gpt-4")
def call_llm(prompt):
    # Your LLM call here
    return "AI response"

@noveum_trace.trace(type="component", agent="data-processor")
def agent_task(task):
    return f"Agent completed: {task}"

# Your functions are now automatically traced!
result = process_data("user input")

โœจ Key Features

๐ŸŽฏ Simplified Decorator Approach

  • Single @trace decorator with parameters instead of multiple decorators
  • Backward compatibility with @observe and @llm_trace aliases
  • Parameter-based specialization for different operation types

๐Ÿค– Multi-Agent Support

  • Agent registry and management with hierarchical relationships
  • Cross-agent correlation and trace propagation
  • Agent-aware context management for complex workflows
  • Thread-safe operations for concurrent agent execution

๐Ÿ” LLM & Tool Call Tracing

  • Auto-instrumentation for OpenAI and Anthropic SDKs
  • Comprehensive LLM metrics (tokens, latency, model info)
  • Tool call tracking with arguments and results
  • OpenTelemetry semantic conventions compliance

๐Ÿ—๏ธ Project-Based Organization

  • Required project ID for proper trace organization
  • Custom headers support (projectId, orgId, additional headers)
  • Environment-aware (development, staging, production)
  • Proper trace ID generation with UUID-based identifiers

๐Ÿ“ฆ Installation

pip install noveum-trace

๐Ÿ”ง Configuration

Basic Initialization

import noveum_trace

# Minimal setup (project_id is required)
tracer = noveum_trace.init(project_id="my-project")

# Full configuration
tracer = noveum_trace.init(
    project_id="my-project",
    project_name="My AI Application",
    org_id="org-123",
    user_id="user-456",
    session_id="session-789",
    environment="production",
    api_key="your-noveum-api-key",  # For Noveum.ai platform
    file_logging=True,
    log_directory="./traces",
    auto_instrument=True,
    capture_content=True,
    custom_headers={"X-Custom-Header": "value"}
)

Environment Variables

export NOVEUM_PROJECT_ID="my-project"
export NOVEUM_API_KEY="your-api-key"
export NOVEUM_ORG_ID="org-123"
export NOVEUM_USER_ID="user-456"
export NOVEUM_SESSION_ID="session-789"
export NOVEUM_ENVIRONMENT="production"

๐ŸŽจ Usage Examples

Simple Function Tracing

@noveum_trace.trace
def data_processing(data):
    # Your processing logic
    return processed_data

@noveum_trace.trace(name="custom-operation")
def custom_function():
    return "result"

LLM Tracing

@noveum_trace.trace(type="llm", model="gpt-4", operation="chat")
def chat_completion(messages):
    response = openai.chat.completions.create(
        model="gpt-4",
        messages=messages
    )
    return response

@noveum_trace.trace(type="llm", model="claude-3", operation="completion")
def text_completion(prompt):
    response = anthropic.messages.create(
        model="claude-3-haiku-20240307",
        messages=[{"role": "user", "content": prompt}]
    )
    return response

Multi-Agent Workflows

from noveum_trace import Agent, AgentConfig, AgentContext, trace

# Define agents
coordinator = Agent(AgentConfig(
    name="coordinator",
    agent_type="orchestrator",
    id="coord-001"
))

worker = Agent(AgentConfig(
    name="data-worker",
    agent_type="processor",
    id="worker-001"
))

# Use agent context
with AgentContext(coordinator):
    @trace
    def plan_task(task):
        # Coordinator planning
        return task_plan

    plan = plan_task("analyze data")

    with AgentContext(worker):
        @trace
        def execute_task(plan):
            # Worker execution
            return results

        results = execute_task(plan)

Tool Call Tracing

@noveum_trace.trace(type="tool", tool_name="web_search")
def search_web(query):
    # Tool implementation
    return search_results

@noveum_trace.trace(type="tool", tool_name="calculator")
def calculate(expression):
    # Calculator implementation
    return result

Dynamic Span Updates

from noveum_trace import trace, update_current_span

@trace
def long_running_task():
    update_current_span(
        metadata={"step": "initialization"},
        progress=10
    )

    # Do some work
    initialize()

    update_current_span(
        metadata={"step": "processing"},
        progress=50
    )

    # More work
    process_data()

    update_current_span(
        metadata={"step": "completion"},
        progress=100
    )

    return "completed"

๐Ÿ”Œ Auto-Instrumentation

The SDK automatically instruments popular LLM libraries:

# Auto-instrumentation is enabled by default
noveum_trace.init(project_id="my-project", auto_instrument=True)

# Now all OpenAI and Anthropic calls are automatically traced
import openai
response = openai.chat.completions.create(...)  # Automatically traced!

import anthropic
response = anthropic.messages.create(...)  # Automatically traced!

๐Ÿ“Š Trace Data Structure

Each trace contains:

{
  "trace_id": "uuid-v4",
  "span_id": "uuid-v4",
  "parent_span_id": "uuid-v4",
  "name": "operation-name",
  "kind": "internal|client|server",
  "status": "ok|error",
  "start_time": "2024-01-01T00:00:00Z",
  "end_time": "2024-01-01T00:00:01Z",
  "duration_ms": 1000,
  "project_id": "my-project",
  "project_name": "My AI Application",
  "org_id": "org-123",
  "user_id": "user-456",
  "session_id": "session-789",
  "environment": "production",
  "attributes": {
    "llm.model": "gpt-4",
    "llm.operation": "chat",
    "gen_ai.system": "openai",
    "gen_ai.usage.input_tokens": 100,
    "gen_ai.usage.output_tokens": 50
  },
  "llm_request": {
    "model": "gpt-4",
    "messages": [...],
    "temperature": 0.7
  },
  "llm_response": {
    "id": "response-id",
    "model": "gpt-4",
    "choices": [...],
    "usage": {
      "prompt_tokens": 100,
      "completion_tokens": 50,
      "total_tokens": 150
    }
  },
  "agent": {
    "name": "data-processor",
    "type": "worker",
    "id": "agent-123"
  },
  "tool_calls": [
    {
      "id": "call-123",
      "name": "web_search",
      "arguments": {"query": "AI news"},
      "result": "search results",
      "duration_ms": 500
    }
  ]
}

๐Ÿ† Competitive Advantages

Feature Noveum Trace DeepEval Phoenix Braintrust
Multi-agent support โœ… โŒ โš ๏ธ โš ๏ธ
Simplified decorators โœ… โœ… โœ… โœ…
Auto agent resolution โœ… โŒ โŒ โŒ
OpenTelemetry compliant โœ… โŒ โœ… โŒ
Project-based organization โœ… โŒ โŒ โŒ
Custom headers โœ… โŒ โŒ โŒ
Trace ID management โœ… โš ๏ธ โœ… โš ๏ธ
Tool call tracing โœ… โŒ โš ๏ธ โš ๏ธ

๐Ÿ“ Project Structure

noveum-trace/
โ”œโ”€โ”€ src/noveum_trace/
โ”‚   โ”œโ”€โ”€ __init__.py              # Main exports
โ”‚   โ”œโ”€โ”€ init.py                  # Simplified initialization
โ”‚   โ”œโ”€โ”€ types.py                 # Type definitions
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ tracer.py           # Main tracer implementation
โ”‚   โ”‚   โ”œโ”€โ”€ span.py             # Span implementation
โ”‚   โ”‚   โ””โ”€โ”€ context.py          # Context management
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”œโ”€โ”€ agent.py            # Agent classes
โ”‚   โ”‚   โ”œโ”€โ”€ registry.py         # Agent registry
โ”‚   โ”‚   โ”œโ”€โ”€ context.py          # Agent context
โ”‚   โ”‚   โ””โ”€โ”€ decorators.py       # Simplified decorators
โ”‚   โ”œโ”€โ”€ sinks/
โ”‚   โ”‚   โ”œโ”€โ”€ base.py             # Base sink interface
โ”‚   โ”‚   โ”œโ”€โ”€ file.py             # File sink
โ”‚   โ”‚   โ”œโ”€โ”€ console.py          # Console sink
โ”‚   โ”‚   โ”œโ”€โ”€ noveum.py           # Noveum.ai sink
โ”‚   โ”‚   โ””โ”€โ”€ elasticsearch.py    # Elasticsearch sink
โ”‚   โ”œโ”€โ”€ instrumentation/
โ”‚   โ”‚   โ”œโ”€โ”€ openai.py           # OpenAI auto-instrumentation
โ”‚   โ”‚   โ””โ”€โ”€ anthropic.py        # Anthropic auto-instrumentation
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ””โ”€โ”€ exceptions.py       # Custom exceptions
โ”œโ”€โ”€ examples/                    # Usage examples
โ”œโ”€โ”€ tests/                      # Test suite
โ”œโ”€โ”€ docs/                       # Documentation
โ””โ”€โ”€ README.md                   # This file

๐Ÿงช Testing

# Run all tests
python -m pytest tests/

# Run specific test categories
python -m pytest tests/unit/
python -m pytest tests/integration/

# Run with coverage
python -m pytest tests/ --cov=noveum_trace

๐Ÿ“š Documentation

๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

๐Ÿ“„ License

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

๐Ÿ†˜ Support

๐Ÿš€ Roadmap

  • JavaScript/TypeScript SDK - Cross-platform support
  • Real-time evaluation - Integration with NovaEval
  • Advanced analytics - Performance insights and recommendations
  • Custom metrics - User-defined metrics and alerts
  • Distributed tracing - Cross-service trace correlation
  • Visual trace explorer - Interactive trace visualization

Built with โค๏ธ 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.1.1.tar.gz (61.6 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.1.1-py3-none-any.whl (68.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: noveum_trace-0.1.1.tar.gz
  • Upload date:
  • Size: 61.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for noveum_trace-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dcc1a64918a7f47cbaf4f4306869224682a41d67e758bb91c8796222cda03ac7
MD5 a3f8730fe0c759994157c34575a0b2b4
BLAKE2b-256 1b3c6903218bdeb584efa4f9c7ea61791674be9c56f22d39b60c79e0a45a5e36

See more details on using hashes here.

File details

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

File metadata

  • Download URL: noveum_trace-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 68.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for noveum_trace-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7cb0dd6039cea6cd6490d3dcefa62fa4f6ce102842cd22f1ac24c32e5babf809
MD5 58c1d3936cb9e5a802a1e8017b09b3c6
BLAKE2b-256 8101a171f6ab5ee6c029a4237eb2980ccaf50ce67963bd68e5a0cf48c0f6a241

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