Skip to main content

Noveum Trace SDK

CI Release codecov PyPI version Python 3.9+ 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
  • ๐Ÿš€ Minimal Setup - Get started in minutes 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

๐Ÿ“ฆ Import Patterns

Noveum Trace supports multiple import patterns. Choose the one that best fits your coding style:

Recommended: Direct Imports from Package Root

This is the recommended approach for most use cases:

from noveum_trace import init, trace_context, NoveumClient
from noveum_trace import trace_llm_call, trace_operation, trace_agent_operation

Available imports from root:

  • Core functions: init, shutdown, flush, configure, get_config, get_client
  • Context managers: trace_context, trace_llm_call, trace_operation, trace_agent_operation, trace_batch_operation, trace_pipeline_stage, create_child_span
  • Core classes: NoveumClient, Trace, Span, ContextualTrace
  • Integrations: NoveumTraceCallbackHandler (LangChain integration)

Alternative: Module-Level Imports

For simple scripts or when you prefer namespace qualification:

import noveum_trace

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

# Use context managers
with noveum_trace.trace_llm_call(model="gpt-4") as span:
    # Your code here
    pass

# Flush traces
noveum_trace.flush()

Submodule Imports (When Needed)

For advanced use cases or when importing items not in the root __all__:

# Integrations (conditional - requires langchain/livekit)
from noveum_trace.integrations.langchain import NoveumTraceCallbackHandler
from noveum_trace.integrations.livekit import (
    LiveKitSTTWrapper,
    LiveKitTTSWrapper,
    setup_livekit_tracing,
)

# Core submodules (also valid, but root imports preferred)
from noveum_trace.core.client import NoveumClient
from noveum_trace.core.span import Span, SpanStatus
from noveum_trace.core.trace import Trace

What Doesn't Work

These import patterns will fail:

# โŒ NoveumTrace class doesn't exist
from noveum_trace import NoveumTrace  # ModuleNotFoundError

# โŒ Wrong path - should be core.client or root import
from noveum_trace.client import NoveumClient  # ModuleNotFoundError
# โœ… Correct:
from noveum_trace import NoveumClient
# or
from noveum_trace.core.client import NoveumClient

Quick Reference Table

What to Import Recommended Import Alternative
Initialize SDK from noveum_trace import init import noveum_trace then noveum_trace.init()
LLM tracing from noveum_trace import trace_llm_call import noveum_trace then noveum_trace.trace_llm_call()
Context manager from noveum_trace import trace_context import noveum_trace then noveum_trace.trace_context()
Client class from noveum_trace import NoveumClient from noveum_trace.core.client import NoveumClient
LangChain integration from noveum_trace.integrations.langchain import NoveumTraceCallbackHandler from noveum_trace.integrations import NoveumTraceCallbackHandler (also works)
LiveKit integration from noveum_trace.integrations.livekit import setup_livekit_tracing from noveum_trace.integrations.livekit import LiveKitSTTWrapper, LiveKitTTSWrapper
Pipecat integration from noveum_trace.integrations.pipecat import NoveumPipecatTracer requires pip install "noveum-trace[pipecat]"
CrewAI integration from noveum_trace.integrations.crewai import NoveumCrewAIListener, setup_crewai_tracing requires Python 3.10+, pip install "noveum-trace[crewai]"

โš™๏ธ Setup

Core Configuration

The SDK requires a few core environment variables to function:

# Required: Your Noveum API key
export NOVEUM_API_KEY="your-api-key"

# Required: Project name for organizing traces
export NOVEUM_PROJECT="your-project-name"

# Optional: Environment name (defaults to "development")
export NOVEUM_ENVIRONMENT="production"

# Optional: Custom API endpoint (defaults to https://api.noveum.ai/api)
export NOVEUM_ENDPOINT="https://api.noveum.ai/api"

Additional Environment Variables

For a complete list of all available environment variables including debug settings, logging configuration, and agent registry limits, see .env.example in the repository root.

๐Ÿ—๏ธ Architecture

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

๐Ÿ”ง Configuration

Environment Variables

The SDK can be configured via environment variables. The core configuration variables are:

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.langchain 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.

๐ŸŽค LiveKit Integration

Automatically trace LiveKit agent sessions with complete observability:

import noveum_trace
from livekit.agents import Agent, AgentSession, JobContext
from livekit.plugins import deepgram, cartesia
from noveum_trace.integrations.livekit import (
    LiveKitSTTWrapper,
    LiveKitTTSWrapper,
    setup_livekit_tracing,
)

# Initialize noveum-trace
noveum_trace.init(project="livekit-agent")

async def agent_entrypoint(ctx: JobContext):
    # Wrap STT/TTS providers for detailed audio tracking
    traced_stt = LiveKitSTTWrapper(
        stt=deepgram.STT(model="nova-2"),
        session_id=ctx.job.id,
        job_context={"job_id": ctx.job.id, "room": ctx.room.name}
    )

    traced_tts = LiveKitTTSWrapper(
        tts=cartesia.TTS(model="sonic-english"),
        session_id=ctx.job.id,
        job_context={"job_id": ctx.job.id}
    )

    # Create session with traced providers
    session = AgentSession(stt=traced_stt, tts=traced_tts)

    # Enable session tracing for automatic event tracking
    # This creates the trace automatically - no need for start_trace()
    setup_livekit_tracing(session)

    agent = Agent(instructions="You are a helpful assistant.")
    await ctx.connect()
    await session.start(agent)  # Complete tracing active!

What Gets Traced

Session Events (automatic):

  • AgentSession Events: State changes, transcriptions, function calls, errors, metrics
  • RealtimeSession Events: Speech detection, transcriptions, generations (when using RealtimeModel)
  • Automatic Trace Creation: Trace is created when session.start() is called

STT/TTS Operations (via wrappers):

  • STT Operations: Transcripts, confidence scores, audio files, durations
  • TTS Operations: Synthesized text, audio files, durations
  • Job Context: Room info, participant details, agent metadata
  • Audio Capture: Automatic saving of audio files for debugging

Key Features

  • โœ… Complete Observability: Session events + detailed STT/TTS tracking
  • โœ… Zero Configuration: Session tracing creates trace automatically
  • โœ… Works with any LiveKit STT/TTS provider
  • โœ… Automatic audio file capture and storage
  • โœ… Rich metadata in span attributes
  • โœ… Graceful degradation (no disruption if tracing fails)

For step-by-step setup instructions, see the LiveKit Integration Guide.

For detailed API documentation, see the LiveKit Integration Docs.

๐Ÿค– Pipecat Integration

Automatically trace Pipecat voice agent pipelines with the two-call NoveumPipecatTracer API โ€” stock transport, no wrappers:

import noveum_trace
from noveum_trace.integrations.pipecat import NoveumPipecatTracer
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.runner import PipelineRunner
from pipecat.pipeline.task import PipelineParams, PipelineTask

# Initialize Noveum Trace
noveum_trace.init(project="pipecat-agent", api_key="your-api-key")

# Create a tracer
tracer = NoveumPipecatTracer(record_audio=True)

async def run_agent():
    pipeline = Pipeline([...])  # Your Pipecat pipeline

    # 1. Wrap the pipeline (use the return value)
    pipeline = tracer.observe_pipeline(pipeline)

    task = PipelineTask(
        pipeline,
        params=PipelineParams(enable_metrics=True, enable_usage_metrics=True),
    )

    # 2. Register handlers (use the return value)
    task = await tracer.register_task_handlers(task, transport=transport)

    runner = PipelineRunner()
    await runner.run(task)

Installation

pip install "noveum-trace[pipecat]"

For full documentation, see the Pipecat Integration Guide.

๐Ÿค CrewAI Integration

Trace CrewAI crews, agents, tasks, and tools automatically:

import noveum_trace
from noveum_trace.integrations.crewai import NoveumCrewAIListener, setup_crewai_tracing
from crewai import Crew, Agent, Task

# Initialize Noveum Trace (Python 3.10+ required for CrewAI)
noveum_trace.init(project="crewai-app", api_key="your-api-key")

# Create your crew
crew = Crew(agents=[...], tasks=[...])

# Option 1: Using the setup factory (recommended)
listener = setup_crewai_tracing()
crew.callback_function = listener
result = crew.kickoff()

# Option 2: Manual instantiation with full control
from noveum_trace import get_client
client = get_client()
listener = NoveumCrewAIListener(client)
crew.callback_function = listener
result = crew.kickoff()

Installation

# Requires Python 3.10+
pip install "noveum-trace[crewai]"

For a complete working example, see docs/examples/crewai_e2e_test.py.

๐Ÿงช 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

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-1.5.21.tar.gz (721.3 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-1.5.21-py3-none-any.whl (410.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: noveum_trace-1.5.21.tar.gz
  • Upload date:
  • Size: 721.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for noveum_trace-1.5.21.tar.gz
Algorithm Hash digest
SHA256 9cdadcddd9aec5b19f32da14d3c6fc378783894d71917550168c0f3494cb0a65
MD5 64a3d164c8ff6f2851bcb81bb4fac98f
BLAKE2b-256 8a9b524a0c1b9109360b2159bdb4183bbefa5c42d5c675a7df56e7c24393a1b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for noveum_trace-1.5.21.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-1.5.21-py3-none-any.whl.

File metadata

  • Download URL: noveum_trace-1.5.21-py3-none-any.whl
  • Upload date:
  • Size: 410.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for noveum_trace-1.5.21-py3-none-any.whl
Algorithm Hash digest
SHA256 03e916d5f45633d0db65092a12e6665634004901dde3d05b6055a4190ac5a3a4
MD5 b575654ab92915c297c55a115a52e53e
BLAKE2b-256 e753177b987931f3fd4366082de43a482187f6983b6b5851a6bf1b65c833c731

See more details on using hashes here.

Provenance

The following attestation bundles were made for noveum_trace-1.5.21-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.

Release history Release notifications | RSS feed

This release

1.5.21 This release

2 files

1.5.20

2 files

1.5.19

2 files

1.5.18

2 files

1.5.17

2 files

1.5.15

2 files

1.5.14

2 files

1.5.13

2 files

1.5.12

2 files

1.5.10

2 files

1.5.9

2 files

1.5.8

2 files

1.5.7

2 files

1.5.4

2 files

1.5.3

2 files

1.5.2

2 files

1.5.0

2 files

1.4.0

2 files

1.3.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page