Netra.init() function configures the SDK and starts the tracing system. Call it once at the start of your application, before making any LLM or database calls.
Quick Start
Configuration Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
app_name / appName | string | Required | Application name for identifying traces in the dashboard |
environment | string | "default" (Py) / "local" (TS) | Deployment environment (e.g., production, staging, development) |
headers | string | "" | Authentication headers, typically x-api-key=YOUR_KEY |
trace_content / traceContent | boolean | true | Capture prompt/completion content from LLM calls. Disable for privacy. |
debug_mode / debugMode | boolean | false | Enable verbose logging for troubleshooting |
disable_batch / disableBatch | boolean | false | Send spans immediately instead of batching |
enable_root_span / enableRootSpan | boolean | false | Create a root span for the entire process (useful for workers) |
resource_attributes / resourceAttributes | dict/object | {} | Custom attributes added to every span |
blocked_spans / blockedSpans | list/array | [] | Span name patterns to exclude (supports * wildcards) |
enable_scrubbing | boolean | false | Auto-redact detected PII (Python only) |
instruments | Set/list | All | Specific instrumentations to enable |
block_instruments / blockInstruments | Set/list | [] | Instrumentations to disable |
For instrumentation control details, see Instrumentation Selection.
Complete Example
Configuration Precedence
Configuration values are resolved in order of priority:- Code parameters - Values passed to
Netra.init() - Netra environment variables -
NETRA_*variables - OpenTelemetry environment variables -
OTEL_*variables - Default values - SDK defaults
Async Initialization (TypeScript)
TheNetra.init() method in TypeScript is async and waits for all instrumentations to be ready before returning. Always await the call to ensure proper instrumentation:
TypeScript
Always
await Netra.init() to ensure libraries like OpenAI, Anthropic, and LangGraph are properly instrumented before use. This is especially important in frameworks like NestJS where modules are loaded after initialization.Shutdown
Ensure all pending spans are exported before application exit:Always call
shutdown() before exit, especially for short-lived processes like serverless functions.Next Steps
- Environment Variables - Configure via environment
- Instrumentation Selection - Control which libraries are traced
- Custom Exporters - Send traces to custom backends