Overview
Metrics let you measure how well your prompts perform. When you record metrics with the same subject used for prompt execution, Switchport automatically aggregates them per prompt version.Basic Usage
Record a metric:Metric Types
Switchport supports three types of metrics:Float Metrics
Numerical values (e.g., ratings, scores, response times):Boolean Metrics
True/false values (e.g., conversions, success rates):Enum Metrics
Categorical values (e.g., sentiment, outcome):Creating Metric Definitions
Before recording metrics, create a metric definition in the dashboard:1
Navigate to Metrics
Go to Metrics → New Metric in the dashboard
2
Configure the metric
- Key: Unique identifier (e.g.,
satisfaction) - Name: Human-readable name (e.g., “User Satisfaction”)
- Type:
float,boolean, orenum
3
Create
Click Create to save the metric definition
Linking Metrics to Prompts
To link metrics to prompt versions, use the same subject for both:Response Object
Therecord method returns a result object:
Error Handling
Handle common errors when recording metrics:Common Patterns
Pattern 1: User Feedback
Pattern 2: Conversion Tracking
Pattern 3: Email Campaign
Pattern 4: Multi-Metric Tracking
Best Practices
Use the same subject
Use the same subject
Always use the same subject for prompt execution and metric recording to ensure proper aggregation.
Record metrics asynchronously
Record metrics asynchronously
Consider recording metrics in a background task to avoid blocking your main application flow.
Handle failures gracefully
Handle failures gracefully
Don’t let metric recording failures break your application. Use try/except blocks and log errors.
Choose appropriate metric types
Choose appropriate metric types
Use the right metric type for your use case:
- Float for numerical measurements
- Boolean for yes/no tracking
- Enum for categorical data
Define metrics early
Define metrics early
Create metric definitions in the dashboard before recording metrics in your code.
Viewing Metrics
Metrics are automatically aggregated per prompt version in the dashboard. You can:- View average values for float metrics
- View success rates for boolean metrics
- View distribution for enum metrics
- Compare metrics across different prompt versions
- Identify winning versions based on metric performance
Next Steps
A/B Testing
Learn how to run A/B tests with metrics
API Reference
See the full metrics API reference

