Netra SDK can be configured using environment variables, providing a flexible way to manage settings without modifying code. This section covers both Netra-specific and standard OpenTelemetry environment variables.

Netra-specific Variables

Netra provides its own set of environment variables for configuring SDK-specific settings:
# Set Netra-specific environment variables
export NETRA_APP_NAME="my-ai-service"
export NETRA_OTLP_ENDPOINT="https://collector.example.com:4318"
export NETRA_API_KEY="your-api-key-here"
export NETRA_ENV="production"
export NETRA_RESOURCE_ATTRS='{"team":"ai", "version":"1.0.0"}'

Available Variables

Variable NameDescriptionDefaultExample Value
NETRA_APP_NAMELogical name for your serviceFalls back to OTEL_SERVICE_NAME or llm_tracing_servicemy-ai-service
NETRA_OTLP_ENDPOINTURL for OTLP collectorFalls back to OTEL_EXPORTER_OTLP_ENDPOINThttps://collector.example.com:4318
NETRA_API_KEYAPI key for authenticationNoneyour-api-key-here
NETRA_HEADERSAdditional headers in W3C Correlation-Context formatNonex-api-key=your-api-key
NETRA_DISABLE_BATCHDisable batch span processor (true/false)falsetrue
NETRA_TRACE_CONTENTWhether to capture prompt/completion content (true/false)truefalse
NETRA_ENVDeployment environment (e.g., prod, staging, dev)localproduction
NETRA_RESOURCE_ATTRSJSON string of custom resource attributes{}{'team': 'ai', 'version': '1.0.0'}

OpenTelemetry Variables

Netra SDK also supports standard OpenTelemetry environment variables for compatibility:
# Set OpenTelemetry environment variables
export OTEL_SERVICE_NAME="my-service"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otel-collector.example.com:4318"
export OTEL_EXPORTER_OTLP_HEADERS="api-key=your-key"
export OTEL_RESOURCE_ATTRIBUTES="team=ai,version=1.0.0"

Available Variables

Variable NameDescriptionUsed WhenExample Value
OTEL_SERVICE_NAMELogical name for your serviceWhen NETRA_APP_NAME is not setmy-service
OTEL_EXPORTER_OTLP_ENDPOINTURL for OTLP collectorWhen NETRA_OTLP_ENDPOINT is not sethttps://otel-collector.example.com:4318
OTEL_EXPORTER_OTLP_HEADERSAdditional headers for OTLP exporterWhen NETRA_HEADERS is not setapi-key=your-key
OTEL_RESOURCE_ATTRIBUTESAdditional resource attributesWhen NETRA_RESOURCE_ATTRS is not setteam=ai,version=1.0.0

Configuration Precedence

Configuration values are resolved in the following order (highest to lowest precedence):
  1. Code Parameters: Values passed directly to Netra.init()
  2. Netra Environment Variables: NETRA_* variables
  3. OpenTelemetry Environment Variables: Standard OTEL_* variables
  4. Default Values: Fallback values defined in the SDK
This allows you to:
  • Override any setting directly in code for maximum control
  • Use Netra-specific environment variables for Netra-specific settings
  • Fall back to standard OpenTelemetry variables for compatibility
  • Rely on sensible defaults when no other configuration is provided