Overview
@kubiks/otel-autumn provides comprehensive OpenTelemetry instrumentation for the Autumn billing SDK. Capture spans for every billing operation including feature checks, usage tracking, checkout flows, product attachments, and cancellations with detailed metadata.

Visualize your billing operations with detailed span information including operation type, customer IDs, feature IDs, and billing metadata.
Installation
Peer Dependencies: 
@opentelemetry/api >= 1.9.0, autumn-js >= 0.1.0Quick Start
instrumentAutumn wraps your Autumn client instance—no configuration changes needed. Every SDK call creates a client span with detailed billing attributes.Traced Operations
This instrumentation wraps the core Autumn billing methods:check
Feature access and product status checks
track
Usage event tracking
checkout
Checkout session creation
attach
Product attachment to customers
cancel
Product cancellation
Span Attributes
Common Attributes (All Operations)
| Attribute | Description | Example | 
|---|---|---|
| billing.system | Constant value autumn | autumn | 
| billing.operation | Operation type | check,track | 
| autumn.resource | Resource being accessed | features,products | 
| autumn.target | Full operation target | features.check | 
| autumn.customer_id | Customer ID | user_123 | 
| autumn.entity_id | Entity ID (if applicable) | org_456 | 
Check Operation
Feature Access Attributes
Feature Access Attributes
| Attribute | Description | Example | 
|---|---|---|
| autumn.feature_id | Feature being checked | messages | 
| autumn.allowed | Whether access is allowed | true | 
| autumn.balance | Current balance/remaining uses | 42 | 
| autumn.usage | Current usage | 8 | 
| autumn.unlimited | Whether usage is unlimited | false | 
| autumn.required_balance | Required balance for operation | 1 | 
Product Status Attributes
Product Status Attributes
| Attribute | Description | Example | 
|---|---|---|
| autumn.product_id | Product being checked | pro | 
| autumn.included_usage | Included usage in plan | 50 | 
Track Operation
| Attribute | Description | Example | 
|---|---|---|
| autumn.feature_id | Feature being tracked | messages | 
| autumn.event_name | Custom event name | message_sent | 
| autumn.value | Usage value tracked | 1 | 
| autumn.event_id | Generated event ID | evt_123 | 
| autumn.idempotency_key | Idempotency key for dedup | msg_456 | 
Checkout Operation
| Attribute | Description | Example | 
|---|---|---|
| autumn.product_id | Product being purchased | pro | 
| autumn.product_ids | Multiple products (comma-separated) | pro, addon_analytics | 
| autumn.checkout_url | Stripe checkout URL | https://checkout.stripe.com/... | 
| autumn.has_prorations | Whether prorations apply | true | 
| autumn.total_amount | Total checkout amount | 2000(cents) | 
| autumn.currency | Currency code | usd | 
| autumn.force_checkout | Whether to force Stripe checkout | false | 
| autumn.invoice | Whether to create invoice | true | 
Attach Operation
| Attribute | Description | Example | 
|---|---|---|
| autumn.product_id | Product being attached | pro | 
| autumn.success | Whether attachment succeeded | true | 
| autumn.checkout_url | Checkout URL if payment needed | https://checkout.stripe.com/... | 
Cancel Operation
| Attribute | Description | Example | 
|---|---|---|
| autumn.product_id | Product being cancelled | pro | 
| autumn.success | Whether cancellation succeeded | true | 
Configuration
You can optionally configure the instrumentation:By default, sensitive customer data is not captured. Enable 
captureCustomerData only if your observability platform is secure and compliant.Usage Examples
Feature Access Control
Usage Tracking
Checkout Flow
Product Management
Complete Integration Example
Here’s a complete example integrating Autumn with a Next.js application:lib/autumn.ts
app/api/features/check/route.ts
app/api/usage/track/route.ts
Best Practices
Use Idempotency Keys
Use Idempotency Keys
Always use idempotency keys when tracking usage to prevent double-counting:
Check Before Usage
Check Before Usage
Check feature access before performing operations:
Handle Checkout Redirects
Handle Checkout Redirects
Handle both checkout URLs and direct product attachments:
Configure Data Capture Carefully
Configure Data Capture Carefully
Only enable additional data capture in secure environments:
Troubleshooting
Spans Not Appearing
Spans Not Appearing
Make sure OpenTelemetry is properly configured in your application:
Missing Attributes
Missing Attributes
Ensure you’re using the latest version of the package:
Performance Impact
Performance Impact
The instrumentation adds minimal overhead. If you experience issues:
- Verify your OpenTelemetry exporter is configured correctly
- Check if you’re using sampling to reduce data volume
- Consider using batch span processors
Resources
Autumn Documentation
Learn more about Autumn billing
GitHub Repository
View source code and examples
npm Package
View package on npm
Report Issues
Found a bug? Let us know!