usage client that lets you query:
- Session-level usage - tokens, requests, and cost per session
- Tenant-level usage - aggregated metrics across a tenant
- Traces - list and iterate through traces within a time range
- Spans - drill into individual spans for a given trace
Netra.usage to retrieve usage and tracing data and how to work efficiently with pagination.
Getting Started
Theusage client is available on the main Netra entry point after initialization.
get_session_usage
Fetch usage metrics for a single session between a start and end time.Parameters
Response: SessionUsageData
get_tenant_usage
Fetch aggregated usage metrics for a tenant across all sessions.Parameters
Response: TenantUsageData
list_traces
Query traces for a time range with optional filtering and pagination.Parameters
Response: TracesPage
TraceSummary Fields
TraceSummary Fields
Direction Values
Direction Values
iter_traces
Iterator that automatically handles pagination when streaming through all traces.Parameters
list_spans_by_trace_id
Fetch spans within a single trace with optional filtering and pagination.Parameters
Response: SpansPage
TraceSpan Fields
TraceSpan Fields
iter_spans_by_trace_id
Iterator that automatically handles pagination when walking through all spans of a trace.Parameters
When to Use Which API
Usage APIs
get_session_usage / get_tenant_usageHigh-level reporting: tokens, requests, and cost per session or tenant. Use for billing dashboards and cost analysis.Traces APIs
list_traces / iter_tracesExplore what traces exist in a time window, optionally filtered by session, user, or tenant. Use for debugging and monitoring.Spans APIs
list_spans_by_trace_id / iter_spans_by_trace_idDrill into a single trace to understand all spans (tools, generations, workflows) that occurred. Use for detailed trace analysis.Iterators
iter_* methodsWhen you need to process all results without manually handling pagination. The iterator fetches pages on-demand.Complete Example
Next Steps
- Dashboard Query - Query dashboard metrics and session stats
- Python SDK Reference - Complete SDK documentation
- Traces Overview - Understanding traces
- Sessions - Session management
