Use Cases
Explore common scenarios supported by the Time Range Blueprint:Serverless Functions
Bill based on function execution time and memory usage.
Container Runtime
Track container running time for usage-based billing.
Compute Instances
Monitor VM runtime and charge by the minute or hour.
Background Jobs
Track processing time for data exports, reports, and batch jobs.
Perfect for billing based on compute time, function execution duration, container runtime, or any time-based usage.
Quick Start
Track resource usage by time duration:1
Install the SDK
2
Get Your API Keys
- Dodo Payments API Key: Get it from Dodo Payments Dashboard
3
Create a Meter
Create a meter in your Dodo Payments Dashboard:
- Event Name:
time_range_usage
(or your preferred name) - Aggregation Type:
sum
to track total duration - Over Property:
durationSeconds
,durationMinutes
, ordurationMs
4
Track Time Usage
Configuration
Ingestion Configuration
Your Dodo Payments API key from the dashboard.
Environment mode:
test_mode
or live_mode
.Event name that matches your meter configuration.
Track Time Range Options
The customer ID for billing attribution.
Duration in milliseconds. Use for sub-second precision.
Duration in seconds. Most common for function execution and short tasks.
Duration in minutes. Useful for longer-running resources like VMs.
Optional metadata about the resource like CPU, memory, region, etc.
Best Practices
Choose the Right Unit: Use milliseconds for short operations, seconds for functions, and minutes for longer-running resources.
Accurate Timing: Use
Date.now()
or performance.now()
for accurate time tracking, especially for serverless functions.