Configuration
Configure the Risicare SDK for your application.
Configure the Risicare SDK to connect to your project and customize tracing behavior.
Basic Setup
import risicare
risicare.init(
api_key="rsk-...", # Or use RISICARE_API_KEY env var
service_name="my-agent", # Identify your service
environment="production", # Environment name
)API Key = Project
Your API key is scoped to the project it was created under (visible in Settings → General). No separate project_id is needed — the gateway resolves it from your key.
Configuration Options
Required
| Option | Type | Description |
|---|---|---|
api_key | str | Your Risicare API key. Starts with rsk-. Each key is scoped to one project. |
Optional
| Option | Type | Default | Description |
|---|---|---|---|
endpoint | str | "https://app.risicare.ai" | Gateway endpoint URL |
environment | str | "development" | Environment name (development, staging, production) |
service_name | str | None | Service name for within-project organization |
service_version | str | None | Service version for traces |
enabled | bool | True | Enable/disable tracing globally |
trace_content | bool | True | Capture prompt/completion content |
sample_rate | float | 1.0 | Sampling rate (0.0-1.0, clamped) |
batch_size | int | 100 | Spans per batch export |
batch_timeout_ms | int | 1000 | Milliseconds between batch exports |
auto_patch | bool | True | Auto-patch ThreadPoolExecutor and asyncio for context propagation |
debug | bool | False | Enable debug logging |
exporters | list[SpanExporter] | None | Custom span exporters (default: HTTP exporter when api_key is provided) |
metadata | dict | {} | Global metadata attached to all spans |
otlp_endpoint | str | None | OTLP/HTTP export endpoint |
otlp_headers | dict | None | OTLP export headers |
otel_bridge | bool | False | Enable OpenTelemetry bridge |
Environment Variables
All configuration can be set via environment variables:
export RISICARE_API_KEY="rsk-..."
export RISICARE_ENDPOINT="https://app.risicare.ai"
export RISICARE_ENVIRONMENT="production"
export RISICARE_SERVICE_NAME="my-agent"
export RISICARE_TRACING="true"
export RISICARE_TRACE_CONTENT="true"
export RISICARE_SAMPLE_RATE="1.0"
export RISICARE_SERVICE_NAME="my-service"
export RISICARE_SERVICE_VERSION="1.0.0"
export RISICARE_DEBUG="false"
export RISICARE_OTLP_ENDPOINT="https://otel-collector:4318"
export RISICARE_OTLP_HEADERS="key1=value1,key2=value2"
export RISICARE_OTEL_BRIDGE="false"| Variable | Maps To |
|---|---|
RISICARE_API_KEY | api_key |
RISICARE_ENDPOINT | endpoint |
RISICARE_ENVIRONMENT | environment |
RISICARE_SERVICE_NAME | service_name |
RISICARE_SERVICE_VERSION | service_version |
RISICARE_TRACING | enabled |
RISICARE_TRACE_CONTENT | trace_content |
RISICARE_SAMPLE_RATE | sample_rate |
RISICARE_DEBUG | debug |
RISICARE_OTLP_ENDPOINT | otlp_endpoint |
RISICARE_OTLP_HEADERS | otlp_headers |
RISICARE_OTEL_BRIDGE | otel_bridge |
Zero-Code Instrumentation
Set RISICARE_TRACING=true to enable auto-instrumentation without any code changes.
Advanced Configuration
Custom Endpoint
For self-hosted deployments:
risicare.init(
api_key="rsk-...",
endpoint="https://your-risicare-instance.com",
)Sampling
Control trace sampling rate:
risicare.init(
api_key="rsk-...",
sample_rate=0.1, # Sample 10% of traces
)Programmatic Control
Check Status
if risicare.is_enabled():
print("Tracing is active")Flush Pending Spans
# Force export all pending spans
client = risicare.get_client()
client.flush()Shutdown
# Graceful shutdown - flushes and closes connections
risicare.shutdown(timeout_ms=5000)Configuration Precedence
Configuration is resolved in this order (highest to lowest priority):
- Explicit
init()parameters - Environment variables
- Default values