Skip to main content

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

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, or durationMs
4

Track Time Usage

Configuration

Ingestion Configuration

string
required
Your Dodo Payments API key from the dashboard.
string
required
Environment mode: test_mode or live_mode.
string
required
Event name that matches your meter configuration.

Track Time Range Options

string
required
The customer ID for billing attribution.
number
Duration in milliseconds. Use for sub-second precision.
number
Duration in seconds. Most common for function execution and short tasks.
number
Duration in minutes. Useful for longer-running resources like VMs.
object
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.
Last modified on March 25, 2026