Skip to main content
This cookbook shows you how to build comprehensive multi-tenant observability for B2B AI platforms—tracking costs per customer, monitoring SLA compliance, and attributing usage across your entire customer base.

Open in Google Colab

Run the complete notebook in your browser
All company names (MeetingMind, Apex Legal, Stratex Consulting, TechStart Inc) and scenarios in this cookbook are entirely fictional and used for demonstration purposes only.

What You’ll Learn

Set Tenant Context

Use Netra’s native tenant tracking to attribute all traces to specific customers

Track Per-Customer Costs

Query usage and cost data per tenant via API or dashboard

Monitor SLA Compliance

Set up tier-specific alerts that trigger on latency or error rate breaches

Analyze Usage Patterns

Understand session and user behavior within each tenant
Prerequisites:

The MeetingMind Scenario

MeetingMind is a fictional B2B SaaS platform that provides AI-powered meeting summarization. The platform serves customers with different needs and budgets: Each tier uses a different configuration and has different SLA commitments:

Step 1: Install Packages

Step 2: Set Environment Variables

Step 3: Initialize Netra for Multi-Tenant Tracking

Initialize Netra at application startup with auto-instrumentation for OpenAI:

Step 4: Define Tenant Configuration

Configure tier-specific settings for each customer:

Step 5: Create Multi-Tenant Meeting Summarizer

Build a service that tracks costs per tenant. This class handles tenant context setting, prompt building based on feature tiers, cost calculation, and SLA compliance checking — all within Netra spans.
The key pattern here is calling set_tenant_id() early in the request lifecycle. This ensures all subsequent traces — including auto-instrumented OpenAI calls — are automatically attributed to the correct tenant.

Step 6: Test with Sample Meetings

Simulate meeting summarization requests from different tenants:

Step 7: Review Usage and Cost Breakdown

Analyze per-tenant usage patterns and costs:

Step 8: SLA Monitoring

Check which tenants are meeting their SLA commitments:

Setting Up Tenant-Specific Alerts

In the Netra dashboard, navigate to Alert Rules and create tenant-filtered alerts:
1

Create Alert Rule

Click Create Alert Rule and name it “Enterprise Latency SLA Breach”
2

Select Scope and Metric

  • Scope: Trace (monitor end-to-end requests)
  • Metric: Latency
3

Apply Tenant Filter

Add a filter for tenant_id = apex-legal to only monitor Enterprise tier requests
4

Set Threshold

  • Condition: Greater than 2000ms
  • Time Window: 5 minutes (to avoid alerting on single slow requests)
5

Configure Contact Point

Select your Slack channel or email for notifications
Create similar alerts for each tier with their respective SLA thresholds:

Step 9: Querying Tenant Metrics via Netra API

Once traces are sent to Netra, query tenant-specific metrics programmatically:

What You’ll See in the Dashboard

After running this cookbook, check the Netra dashboard for:
  • Tenant selector filtering all traces to a specific customer
  • Per-tenant cost breakdown showing usage per customer
  • SLA compliance dashboard with latency metrics by tier
  • Comparative analytics showing which customers use which features
  • User activity filtered by tenant and user ID

Key Multi-Tenant Patterns

See Also

A/B Testing Configurations

Evaluate whether your tier configurations deliver the right quality

Tenants Documentation

Deep dive into tenant tracking features

Usage APIs

Query usage data programmatically

Alert Rules

Set up proactive monitoring
Last modified on March 17, 2026