Skip to main content
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

VariableDescriptionExample
NETRA_API_KEYAPI key for authenticating with Netrantr_abc123...
NETRA_OTLP_ENDPOINTOTLP endpoint URL for sending tracesSee region endpoints below
NETRA_HEADERSCustom headers in W3C Correlation-Context formatx-api-key=abc123,x-custom=value
Use the endpoint that matches your selected data region:
RegionEndpoint
UShttps://api.getnetra.ai/telemetry
EUhttps://api.eu.getnetra.ai/telemetry
export NETRA_API_KEY="your-api-key-here"
export NETRA_OTLP_ENDPOINT="https://api.getnetra.ai/telemetry"

Application Identity

VariableDescriptionExample
NETRA_APP_NAMEName of your applicationmy-ai-service
NETRA_ENVDeployment environmentproduction, staging, development
export NETRA_APP_NAME="my-ai-service"
export NETRA_ENV="production"

Tracing Behavior

VariableDescriptionDefault
NETRA_TRACE_CONTENTCapture prompt/completion content (true/false)true
NETRA_DISABLE_BATCHSend spans immediately without batching (true/false)false
NETRA_ENABLE_ROOT_SPANCreate long-lived root span (true/false)false
NETRA_ENABLE_SCRUBBINGEnable PII scrubbing (Python only) (true/false)false
NETRA_DEBUGEnable debug logging (true/false)false
# Production settings
export NETRA_TRACE_CONTENT="true"
export NETRA_DISABLE_BATCH="false"
export NETRA_DEBUG="false"

# Development settings
export NETRA_TRACE_CONTENT="true"
export NETRA_DISABLE_BATCH="true"  # Immediate export for debugging
export NETRA_DEBUG="true"

Attribute Limits

VariableDescriptionDefault
NETRA_ATTRIBUTE_MAX_LENMaximum length for span attribute values50000
NETRA_CONVERSATION_CONTENT_MAX_LENMaximum length for conversation content50000
# Increase limits for verbose applications
export NETRA_ATTRIBUTE_MAX_LEN="100000"
export NETRA_CONVERSATION_CONTENT_MAX_LEN="100000"

Resource Attributes

VariableDescriptionExample
NETRA_RESOURCE_ATTRSJSON 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.
VariableNetra EquivalentDescription
OTEL_SERVICE_NAMENETRA_APP_NAMEService/application name
OTEL_EXPORTER_OTLP_ENDPOINTNETRA_OTLP_ENDPOINTOTLP exporter endpoint
OTEL_EXPORTER_OTLP_HEADERSNETRA_HEADERSOTLP exporter headers
OTEL_RESOURCE_ATTRIBUTESNETRA_RESOURCE_ATTRSResource 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:
  1. Code parameters (highest priority)
    Netra.init(app_name="code-value")  # This wins
    
  2. Netra environment variables
    export NETRA_APP_NAME="netra-env-value"
    
  3. OpenTelemetry environment variables
    export OTEL_SERVICE_NAME="otel-env-value"
    
  4. 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

VariableTypeDefaultDescription
NETRA_API_KEYstring-API key for authentication
NETRA_OTLP_ENDPOINTstring-OTLP endpoint URL
NETRA_HEADERSstring-Custom headers (W3C format)
NETRA_APP_NAMEstring-Application name
NETRA_ENVstringdefaultEnvironment name
NETRA_TRACE_CONTENTbooleantrueCapture prompt/completion content
NETRA_DISABLE_BATCHbooleanfalseDisable span batching
NETRA_ENABLE_ROOT_SPANbooleanfalseEnable root span
NETRA_ENABLE_SCRUBBINGbooleanfalseEnable PII scrubbing (Python)
NETRA_DEBUGbooleanfalseEnable debug logging
NETRA_ATTRIBUTE_MAX_LENinteger50000Max attribute length
NETRA_CONVERSATION_CONTENT_MAX_LENinteger50000Max conversation length
NETRA_RESOURCE_ATTRSJSON string{}Custom resource attributes

Next Steps

Last modified on February 3, 2026