Skip to main content
Auto-instrumentation is the easiest way to start tracing your AI applications. When you call Netra.init(), the SDK automatically detects and instruments supported libraries in your application, capturing traces without requiring any code changes.

How It Works

Netra uses monkey-patching to intercept calls to supported libraries at runtime. When your application makes a call to an LLM provider, vector database, or HTTP client, Netra automatically:
  1. Creates a span for the operation
  2. Captures input parameters (prompts, queries, etc.)
  3. Records output data (completions, results, etc.)
  4. Measures latency and performance metrics
  5. Tracks token usage and costs (for LLM calls)
All of this happens transparently without modifying your existing code.

Quick Start

Initialize Netra at the start of your application to enable auto-instrumentation:
from netra import Netra

# Initialize before importing other libraries for best results
Netra.init(app_name="my-ai-app", environment="production")

# Your existing code works unchanged
from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}],
)
# This call is automatically traced
For best results, initialize Netra before importing the libraries you want to instrument. This ensures all calls are captured from the start.

What Gets Captured

For each instrumented call, Netra captures relevant attributes based on the operation type:

LLM Calls

AttributeDescription
gen_ai.systemThe LLM provider (e.g., “openai”, “anthropic”)
gen_ai.request.modelModel name used for the request
gen_ai.promptInput prompt (if trace_content is enabled)
gen_ai.completionGenerated response (if trace_content is enabled)
gen_ai.usage.prompt_tokensNumber of input tokens
gen_ai.usage.completion_tokensNumber of output tokens
gen_ai.usage.total_tokensTotal tokens used

Vector Database Operations

AttributeDescription
db.systemDatabase type (e.g., “pinecone”, “qdrant”)
db.operationOperation type (e.g., “query”, “upsert”)
db.vector.query.top_kNumber of results requested

HTTP Requests

AttributeDescription
http.methodHTTP method (GET, POST, etc.)
http.urlRequest URL
http.status_codeResponse status code
http.request.bodyRequest body (if enabled)
http.response.bodyResponse body (if enabled)

Controlling Content Capture

By default, Netra captures prompt and completion content. You can disable this for privacy or compliance reasons:
Netra.init(
    app_name="my-ai-app",
    trace_content=False,  # Disable prompt/completion capture
)
When trace_content is disabled, Netra still captures:
  • Token counts and usage metrics
  • Latency and performance data
  • Model names and configuration
  • Error information

Selective Instrumentation

You can control which libraries are instrumented. See Instrumentation Selection for details on:
  • Enabling only specific instrumentations
  • Blocking certain instrumentations
  • Fine-tuning what gets captured

Combining with Manual Tracing

Auto-instrumentation works seamlessly with manual tracing. You can add custom spans and attributes to provide additional context:
from netra import Netra
from openai import OpenAI

Netra.init(app_name="my-ai-app")

client = OpenAI()

# Create a parent span for your workflow
with Netra.start_span("process-user-query") as span:
    span.set_attribute("user.query", user_query)

    # Auto-instrumented OpenAI call appears as a child span
    response = client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": user_query}],
    )

Supported Instrumentations

Netra supports a wide range of libraries across both Python and TypeScript. For detailed integration guides, see the Integrations section.

LLM Providers

Automatically trace completions, embeddings, and other API calls to major LLM providers.
ProviderPythonTypeScript
OpenAIopenaiopenai
Anthropicanthropic-
Google Generative AIgoogle-generativeai@google/generative-ai
Coherecohere-
Mistralmistralai@mistralai/mistralai
Groqgroqgroq-sdk
AWS Bedrockboto3-
Vertex AIgoogle-cloud-aiplatform@google-cloud/vertexai
Ollamaollama-
Replicatereplicate-
Together AItogethertogether-ai
Hugging Facetransformers-
LiteLLMlitellm-

AI Frameworks

Capture chain executions, agent steps, and tool calls from popular AI orchestration frameworks.
FrameworkPythonTypeScript
LangChainlangchainlangchain
LangGraphlanggraph@langchain/langgraph
LlamaIndexllama-indexllamaindex
Haystackhaystack-
CrewAIcrewai-
DSPydspy-
Pydantic AIpydantic-ai-

Vector Databases

Track similarity searches, upserts, and other vector operations for RAG pipelines.
DatabasePythonTypeScript
Pineconepinecone-client@pinecone-database/pinecone
Weaviateweaviate-client-
Qdrantqdrant-client@qdrant/js-client-rest
ChromaDBchromadbchromadb
Milvuspymilvus-
LanceDBlancedb-
Marqomarqo-

Web Frameworks

Instrument incoming HTTP requests to trace your API endpoints end-to-end.
FrameworkPythonTypeScript
FastAPIfastapi-
Flaskflask-
Djangodjango-
Starlettestarlette-
Express-express
Fastify-fastify
NestJS-@nestjs/core

HTTP Clients

Capture outgoing HTTP requests to external services and APIs.
ClientPythonTypeScript
HTTPXhttpx-
AIOHTTPaiohttp-
Requestsrequests-
urllib3urllib3-
Fetch-Built-in
HTTP/HTTPS-Built-in

Databases

Monitor database queries and operations for performance analysis.
DatabasePythonTypeScript
PostgreSQLpsycopg2, psycopgpg
MySQLpymysqlmysql2
MongoDBpymongomongodb
Redisredisredis, ioredis
SQLAlchemysqlalchemy-
SQLitesqlite3-
Elasticsearchelasticsearch-
Prisma-@prisma/client
TypeORM-typeorm

Message Queues

Trace asynchronous task processing and message-based workflows.
QueuePythonTypeScript
Celerycelery-
RabbitMQpika, aio-pikaamqplib
Kafkakafka-python, confluent-kafkakafkajs
AWS SQSboto3-

Next Steps

Last modified on February 2, 2026