By default, Netra instruments all supported libraries detected in your application. You can customize this behavior to enable only specific instrumentations or to block certain ones.
How It Works
Netra provides two parameters for controlling instrumentations:
| Parameter | Behavior |
|---|
instruments | When provided, only these instrumentations are enabled |
block_instruments | These instrumentations are excluded from the default set |
Use instruments when you want a minimal setup with only specific libraries traced. Use block_instruments when you want most instrumentations but need to exclude a few.
Enabling Specific Instrumentations
Use the instruments parameter to enable only the instrumentations you need:
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet
Netra.init(
app_name="my-ai-app",
instruments={
InstrumentSet.OPENAI,
InstrumentSet.PINECONE,
InstrumentSet.LANGCHAIN,
},
)
Blocking Specific Instrumentations
Use block_instruments to exclude certain instrumentations while keeping all others:
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet
# Instrument everything except HTTP clients
Netra.init(
app_name="my-ai-app",
block_instruments={
InstrumentSet.HTTPX,
InstrumentSet.AIOHTTP,
InstrumentSet.REQUESTS,
},
)
Available Instruments
Python Instruments
LLM Providers
| Instrument | Description |
|---|
InstrumentSet.OPENAI | OpenAI API calls |
InstrumentSet.ANTHROPIC | Anthropic Claude API |
InstrumentSet.COHERE | Cohere API |
InstrumentSet.GOOGLE_GENERATIVEAI | Google Generative AI |
InstrumentSet.MISTRALAI | Mistral AI API |
InstrumentSet.GROQ | Groq API |
InstrumentSet.BEDROCK | AWS Bedrock |
InstrumentSet.VERTEXAI | Google Vertex AI |
InstrumentSet.OLLAMA | Ollama local models |
InstrumentSet.REPLICATE | Replicate API |
InstrumentSet.TOGETHER | Together AI |
InstrumentSet.TRANSFORMERS | Hugging Face Transformers |
InstrumentSet.LITELLM | LiteLLM unified interface |
AI Frameworks
| Instrument | Description |
|---|
InstrumentSet.LANGCHAIN | LangChain framework |
InstrumentSet.LANGGRAPH | LangGraph workflows |
InstrumentSet.LLAMAINDEX | LlamaIndex framework |
InstrumentSet.HAYSTACK | Haystack framework |
InstrumentSet.CREWAI | CrewAI agents |
InstrumentSet.DSPY | DSPy framework |
InstrumentSet.PYDANTIC_AI | Pydantic AI |
Vector Databases
| Instrument | Description |
|---|
InstrumentSet.PINECONE | Pinecone vector database |
InstrumentSet.WEAVIATE | Weaviate vector database |
InstrumentSet.QDRANT | Qdrant vector database |
InstrumentSet.CHROMADB | ChromaDB vector database |
InstrumentSet.MILVUS | Milvus vector database |
InstrumentSet.LANCEDB | LanceDB vector database |
InstrumentSet.MARQO | Marqo vector database |
HTTP Clients
| Instrument | Description |
|---|
InstrumentSet.HTTPX | HTTPX async client |
InstrumentSet.AIOHTTP | AIOHTTP async client |
InstrumentSet.REQUESTS | Requests library |
InstrumentSet.URLLIB | urllib library |
InstrumentSet.URLLIB3 | urllib3 library |
Web Frameworks
| Instrument | Description |
|---|
InstrumentSet.FASTAPI | FastAPI framework |
InstrumentSet.FLASK | Flask framework |
InstrumentSet.DJANGO | Django framework |
InstrumentSet.STARLETTE | Starlette framework |
InstrumentSet.TORNADO | Tornado framework |
InstrumentSet.FALCON | Falcon framework |
Databases
| Instrument | Description |
|---|
InstrumentSet.SQLALCHEMY | SQLAlchemy ORM |
InstrumentSet.SQLITE3 | SQLite3 |
InstrumentSet.PSYCOPG | PostgreSQL (psycopg) |
InstrumentSet.PSYCOPG2 | PostgreSQL (psycopg2) |
InstrumentSet.PYMYSQL | MySQL |
InstrumentSet.PYMONGO | MongoDB |
InstrumentSet.REDIS | Redis |
InstrumentSet.ELASTICSEARCH | Elasticsearch |
Message Queues
| Instrument | Description |
|---|
InstrumentSet.CELERY | Celery task queue |
InstrumentSet.PIKA | RabbitMQ (pika) |
InstrumentSet.AIO_PIKA | RabbitMQ (aio-pika) |
InstrumentSet.KAFKA_PYTHON | Kafka |
InstrumentSet.CONFLUENT_KAFKA | Confluent Kafka |
TypeScript Instruments
LLM Providers
| Instrument | Description |
|---|
NetraInstrumentSet.OPENAI | OpenAI API calls |
NetraInstrumentSet.GOOGLE_GENAI | Google Generative AI |
NetraInstrumentSet.MISTRAL | Mistral AI API |
NetraInstrumentSet.GROQ | Groq API |
NetraInstrumentSet.VERTEX_AI | Google Vertex AI |
NetraInstrumentSet.TOGETHER | Together AI |
AI Frameworks
| Instrument | Description |
|---|
NetraInstrumentSet.LANGCHAIN | LangChain framework |
NetraInstrumentSet.LANGGRAPH | LangGraph workflows |
NetraInstrumentSet.LLAMAINDEX | LlamaIndex framework |
Vector Databases
| Instrument | Description |
|---|
NetraInstrumentSet.PINECONE | Pinecone vector database |
NetraInstrumentSet.QDRANT | Qdrant vector database |
NetraInstrumentSet.CHROMADB | ChromaDB vector database |
HTTP Clients
| Instrument | Description |
|---|
NetraInstrumentSet.HTTP | Node.js HTTP module |
NetraInstrumentSet.HTTPS | Node.js HTTPS module |
NetraInstrumentSet.FETCH | Fetch API |
Web Frameworks
| Instrument | Description |
|---|
NetraInstrumentSet.EXPRESS | Express.js framework |
NetraInstrumentSet.FASTIFY | Fastify framework |
NetraInstrumentSet.NESTJS | NestJS framework |
Databases
| Instrument | Description |
|---|
NetraInstrumentSet.PRISMA | Prisma ORM |
NetraInstrumentSet.TYPEORM | TypeORM |
NetraInstrumentSet.MONGODB | MongoDB |
NetraInstrumentSet.POSTGRES | PostgreSQL |
NetraInstrumentSet.MYSQL | MySQL |
NetraInstrumentSet.REDIS | Redis |
Message Queues
| Instrument | Description |
|---|
NetraInstrumentSet.KAFKA | Kafka |
NetraInstrumentSet.RABBITMQ | RabbitMQ |
Common Use Cases
LLM-Only Tracing
Trace only LLM provider calls, ignoring HTTP, database, and framework instrumentation:
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet
Netra.init(
app_name="llm-only-app",
instruments={
InstrumentSet.OPENAI,
InstrumentSet.ANTHROPIC,
InstrumentSet.GOOGLE_GENERATIVEAI,
},
)
Reduce HTTP Noise
Block HTTP client instrumentation to reduce trace noise while keeping everything else:
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet
Netra.init(
app_name="my-ai-app",
block_instruments={
InstrumentSet.HTTPX,
InstrumentSet.AIOHTTP,
InstrumentSet.REQUESTS,
InstrumentSet.URLLIB,
InstrumentSet.URLLIB3,
},
)
RAG Application
Instrument only what’s needed for a typical RAG application:
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet
Netra.init(
app_name="rag-app",
instruments={
# LLM provider
InstrumentSet.OPENAI,
# Vector database
InstrumentSet.PINECONE,
# Framework
InstrumentSet.LANGCHAIN,
},
)
API Service
Instrument a FastAPI/Express service with database and LLM calls:
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet
Netra.init(
app_name="api-service",
instruments={
# Web framework
InstrumentSet.FASTAPI,
# LLM
InstrumentSet.OPENAI,
# Database
InstrumentSet.SQLALCHEMY,
InstrumentSet.REDIS,
},
)
Best Practices
-
Start broad, then narrow - Begin with default instrumentation (all libraries), then use
block_instruments to remove noisy ones.
-
Use
instruments for minimal setups - When you know exactly which libraries you need traced, use instruments for a cleaner configuration.
-
Block HTTP for cleaner traces - HTTP instrumentation can create many spans. Block it if you don’t need to trace external API calls.
-
Match your dependencies - Only include instruments for libraries you actually use. Extra instruments have minimal overhead but can cause confusion.
-
Document your choices - Add comments explaining why certain instrumentations are enabled or blocked.
Netra.init(
app_name="my-app",
block_instruments={
# Block HTTP to reduce noise - we only care about LLM calls
InstrumentSet.HTTPX,
InstrumentSet.REQUESTS,
},
)
Troubleshooting
Instrumentation not working
-
Check library installation order - Initialize Netra before importing the library you want to instrument.
-
Verify the instrument name - Ensure you’re using the correct enum value for your SDK version.
-
Enable debug mode - Use
debug_mode=True to see which instrumentations are being loaded.
Too many spans
-
Block HTTP clients - HTTP instrumentation often creates the most spans.
-
Use
instruments - Switch from blocking to allowlisting for more control.
-
Use
blocked_spans - Filter specific span names at export time (see Initialization).
Next Steps