Skip to main content

Installation

Run the following command to install Netra in your environment
pip install netra-sdk

Optional Dependencies

Netra SDK supports optional dependencies for enhanced functionality:

Presidio for PII Detetcion

To use the PII detection features provided by Netra SDK:
pip install 'netra-sdk[presidio]'
If you try to use the PII detection utility in Netra SDK without installing this dependency, you will receive an exception. So, always make sure to install the package if you plan to use this utility.Hero Light

Initialization

API Key Configuration

To enable Netra SDK tracing, you need to provide an API key. You can obtain your API key from the Netra dashboard. Api Key Pn

Environment Variable Configuration

Add the following environment variables to your application to enable Netra SDK tracing.
export NETRA_OTLP_ENDPOINT="https://api.eu.getnetra.ai/telemetry"
export NETRA_API_KEY="your-api-key-here"

Code Snippet

Follow the code below to initialize Netra in you application. By default, Netra will instrument all the installed packages.
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet

# Initialize with default settings
Netra.init(app_name="Your application name")

# Or with custom configuration
api_key = "Your API key"
headers = f"x-api-key={api_key}"
Netra.init(
    app_name="Your application name",
    headers=headers,
    trace_content=True,
    environment="Your Application environment"
)
Calling Netra.init() starts basic tracing, but to get useful insights, it is recommended to add custom annotations and manual instrumentation around important parts of your code.

Decorators for Easy Instrumentation

Netra SDK provides decorators like @workflow, @agent, and @task for easy instrumentation of your code. For more details and usage examples, please refer to the Decorators section in our documentation.