Documentation Index
Fetch the complete documentation index at: https://docs.getnetra.ai/llms.txt
Use this file to discover all available pages before exploring further.
Environment variables provide a way to configure Netra without modifying code. This is useful for managing different configurations across environments (development, staging, production) and for keeping sensitive values like API keys out of your codebase.
Netra Environment Variables
These variables are specific to the Netra SDK:
Authentication and Endpoint
| Variable | Description | Example |
|---|
NETRA_API_KEY | API key for authenticating with Netra | ntr_abc123... |
NETRA_OTLP_ENDPOINT | OTLP endpoint URL for sending traces | See region endpoints below |
NETRA_HEADERS | Custom headers in W3C Correlation-Context format | x-api-key=abc123,x-custom=value |
Use the endpoint that matches your selected data region:
| Region | Endpoint |
|---|
| US | https://api.getnetra.ai/telemetry |
| EU | https://api.eu.getnetra.ai/telemetry |
export NETRA_API_KEY="your-api-key-here"
export NETRA_OTLP_ENDPOINT="https://api.getnetra.ai/telemetry"
Application Identity
| Variable | Description | Example |
|---|
NETRA_APP_NAME | Name of your application | my-ai-service |
NETRA_ENV | Deployment environment | production, staging, development |
export NETRA_APP_NAME="my-ai-service"
export NETRA_ENV="production"
Tracing Behavior
| Variable | Description | Default |
|---|
NETRA_TRACE_CONTENT | Capture prompt/completion content (true/false) | true |
NETRA_DISABLE_BATCH | Send spans immediately without batching (true/false) | false |
NETRA_ENABLE_ROOT_SPAN | Create long-lived root span (true/false) | false |
NETRA_ENABLE_SCRUBBING | Enable PII scrubbing (Python only) (true/false) | false |
NETRA_DEBUG | Enable debug logging (true/false) | false |
BLOCKED_URL_PATTERNS | Block internal request calls by URL pattern matching | None |
# Production settings
export NETRA_TRACE_CONTENT="true"
export NETRA_DISABLE_BATCH="false"
export NETRA_DEBUG="false"
export BLOCKED_URL_PATTERNS="getnetra.ai"
# Development settings
export NETRA_TRACE_CONTENT="true"
export NETRA_DISABLE_BATCH="true" # Immediate export for debugging
export NETRA_DEBUG="true"
export BLOCKED_URL_PATTERNS="dev.getnetra.ai"
Attribute Limits
| Variable | Description | Default |
|---|
NETRA_ATTRIBUTE_MAX_LEN | Maximum length for span attribute values | 50000 |
NETRA_CONVERSATION_CONTENT_MAX_LEN | Maximum length for conversation content | 50000 |
# Increase limits for verbose applications
export NETRA_ATTRIBUTE_MAX_LEN="100000"
export NETRA_CONVERSATION_CONTENT_MAX_LEN="100000"
Resource Attributes
| Variable | Description | Example |
|---|
NETRA_RESOURCE_ATTRS | JSON string of custom resource attributes | {"team":"ml","version":"1.0"} |
export NETRA_RESOURCE_ATTRS='{"deployment.version":"1.2.3","team":"ml-platform"}'
OpenTelemetry Environment Variables
Netra also respects standard OpenTelemetry environment variables. These serve as fallbacks when Netra-specific variables are not set.
| Variable | Netra Equivalent | Description |
|---|
OTEL_SERVICE_NAME | NETRA_APP_NAME | Service/application name |
OTEL_EXPORTER_OTLP_ENDPOINT | NETRA_OTLP_ENDPOINT | OTLP exporter endpoint |
OTEL_EXPORTER_OTLP_HEADERS | NETRA_HEADERS | OTLP exporter headers |
OTEL_RESOURCE_ATTRIBUTES | NETRA_RESOURCE_ATTRS | Resource attributes |
# These work as fallbacks (use endpoint matching your region)
export OTEL_SERVICE_NAME="my-ai-service"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.getnetra.ai/telemetry" # US region
# export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.eu.getnetra.ai/telemetry" # EU region
export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-key"
Configuration Precedence
When the same setting is configured in multiple places, Netra uses this priority order:
-
Code parameters (highest priority)
Netra.init(app_name="code-value") # This wins
-
Netra environment variables
export NETRA_APP_NAME="netra-env-value"
-
OpenTelemetry environment variables
export OTEL_SERVICE_NAME="otel-env-value"
-
Default values (lowest priority)
Example
# Environment
export NETRA_APP_NAME="env-app"
export OTEL_SERVICE_NAME="otel-app"
# Code
Netra.init(app_name="code-app") # Uses "code-app"
Netra.init() # Uses "env-app" (NETRA_ takes precedence over OTEL_)
Environment-Specific Configuration
Development
# .env.development
NETRA_API_KEY="dev-api-key"
NETRA_OTLP_ENDPOINT="https://api.getnetra.ai/telemetry" # Use endpoint matching your region
NETRA_APP_NAME="my-app-dev"
NETRA_ENV="development"
NETRA_DEBUG="true"
NETRA_DISABLE_BATCH="true"
NETRA_TRACE_CONTENT="true"
Staging
# .env.staging
NETRA_API_KEY="staging-api-key"
NETRA_OTLP_ENDPOINT="https://api.getnetra.ai/telemetry" # Use endpoint matching your region
NETRA_APP_NAME="my-app-staging"
NETRA_ENV="staging"
NETRA_DEBUG="false"
NETRA_DISABLE_BATCH="false"
NETRA_TRACE_CONTENT="true"
Production
# .env.production
NETRA_API_KEY="prod-api-key"
NETRA_OTLP_ENDPOINT="https://api.getnetra.ai/telemetry" # Use endpoint matching your region
NETRA_APP_NAME="my-app"
NETRA_ENV="production"
NETRA_DEBUG="false"
NETRA_DISABLE_BATCH="false"
NETRA_TRACE_CONTENT="true"
NETRA_ENABLE_SCRUBBING="true" # Enable PII protection in production
Loading Environment Variables
Python
# Using python-dotenv
from dotenv import load_dotenv
load_dotenv() # Load from .env file
from netra import Netra
Netra.init() # Automatically picks up environment variables
TypeScript/Node.js
// Using dotenv
import "dotenv/config";
import { Netra } from "netra-sdk";
await Netra.init({
appName: process.env.NETRA_APP_NAME || "my-app",
});
Docker and Kubernetes
Docker
# Dockerfile
ENV NETRA_APP_NAME="my-app"
ENV NETRA_ENV="production"
# docker run
docker run -e NETRA_API_KEY="your-key" -e NETRA_ENV="production" my-app
Docker Compose
# docker-compose.yml
services:
app:
image: my-app
environment:
- NETRA_API_KEY=${NETRA_API_KEY}
- NETRA_OTLP_ENDPOINT=https://api.getnetra.ai/telemetry # Use endpoint matching your region
- NETRA_APP_NAME=my-app
- NETRA_ENV=production
Kubernetes
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
template:
spec:
containers:
- name: my-app
env:
- name: NETRA_API_KEY
valueFrom:
secretKeyRef:
name: netra-secrets
key: api-key
- name: NETRA_OTLP_ENDPOINT
value: "https://api.getnetra.ai/telemetry" # Use endpoint matching your region
- name: NETRA_APP_NAME
value: "my-app"
- name: NETRA_ENV
value: "production"
# secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: netra-secrets
type: Opaque
stringData:
api-key: "your-netra-api-key"
Complete Reference
| Variable | Type | Default | Description |
|---|
NETRA_API_KEY | string | - | API key for authentication |
NETRA_OTLP_ENDPOINT | string | - | OTLP endpoint URL |
NETRA_HEADERS | string | - | Custom headers (W3C format) |
NETRA_APP_NAME | string | - | Application name |
NETRA_ENV | string | default | Environment name |
NETRA_TRACE_CONTENT | boolean | true | Capture prompt/completion content |
NETRA_DISABLE_BATCH | boolean | false | Disable span batching |
NETRA_ENABLE_ROOT_SPAN | boolean | false | Enable root span |
NETRA_ENABLE_SCRUBBING | boolean | false | Enable PII scrubbing (Python) |
NETRA_DEBUG | boolean | false | Enable debug logging |
NETRA_ATTRIBUTE_MAX_LEN | integer | 50000 | Max attribute length |
NETRA_CONVERSATION_CONTENT_MAX_LEN | integer | 50000 | Max conversation length |
NETRA_RESOURCE_ATTRS | JSON string | {} | Custom resource attributes |
Next Steps