Subscription Monitoring
Monitor your Meteor DDP subscriptions with detailed performance metrics.
What Gets Tracked
For each subscription, SkySignal captures:
| Field | Description |
|---|---|
subscriptionName | The name of the publication |
responseTime | Time to initial data delivery |
documentsAdded | Number of documents sent |
documentsChanged | Documents updated during subscription |
documentsRemoved | Documents removed during subscription |
dataTransferred | Approximate bytes transferred |
userId | The subscribing user |
timestamp | When the subscription started |
Viewing Subscription Data
Subscriptions Dashboard
Navigate to your site's Subscriptions tab to see:
- Active Subscriptions - Currently active subscription count
- Response Time Trends - Historical performance data
- Top Subscriptions - Most frequently used publications
- Data Transfer - Bandwidth usage by subscription
Subscription Details
Click on any subscription to view:
- Average response time and percentiles
- Document count statistics
- Data transfer metrics
- Sample subscription instances
Configuration
Enable/Disable Subscription Tracking
SkySignal.init({
apiKey: '...',
trackSubscriptions: true, // Enable (default)
});
Ignore Specific Subscriptions
Exclude subscriptions from tracking:
SkySignal.init({
apiKey: '...',
ignoreSubscriptions: [
'meteor.loginServiceConfiguration', // Built-in Meteor sub
/^internal\./, // Internal subscriptions
],
});
Understanding Metrics
Response Time
The time from subscription request to onReady() callback:
// In your client code
Meteor.subscribe('posts', function onReady() {
// SkySignal measures time until this callback fires
});
Document Metrics
- Added - Initial documents sent when subscription starts
- Changed - Updates pushed to the client
- Removed - Documents removed from the subscription
Data Transfer
Estimated bytes transferred, calculated from:
- EJSON-serialized document size
- Number of documents sent
Performance Insights
Identifying Large Subscriptions
Watch for subscriptions with:
- High
documentsAddedcounts (sending too much data initially) - Large
dataTransferredvalues - Long response times
Common Issues
Subscription sends too many documents
// Bad: Publishes all posts
Meteor.publish('posts', function() {
return Posts.find(); // Could be thousands of documents!
});
// Good: Limit and paginate
Meteor.publish('posts', function(limit = 20) {
check(limit, Number);
return Posts.find({}, {
limit: Math.min(limit, 100),
sort: { createdAt: -1 }
});
});
Subscription is slow to become ready
Common causes:
- Large initial dataset
- Missing database indexes
- Complex publication logic
Best Practices
1. Paginate Large Collections
Never send all documents at once:
Meteor.publish('posts.paginated', function(page = 1, limit = 20) {
check(page, Number);
check(limit, Number);
const skip = (page - 1) * limit;
return Posts.find({}, {
skip,
limit: Math.min(limit, 100),
sort: { createdAt: -1 }
});
});
2. Use Field Filtering
Only publish needed fields:
Meteor.publish('users.list', function() {
return Meteor.users.find({}, {
fields: {
username: 1,
'profile.avatar': 1,
// Don't send emails, settings, etc.
}
});
});
3. Index Your Queries
Ensure MongoDB indexes exist for your publication queries:
// In your collection file
Posts.createIndex({ createdAt: -1 });
Posts.createIndex({ authorId: 1, createdAt: -1 });
4. Consider Publication Merging
For complex UIs, consider using reywood:publish-composite:
Meteor.publishComposite('postWithAuthor', function(postId) {
return {
find() {
return Posts.find({ _id: postId });
},
children: [{
find(post) {
return Meteor.users.find({ _id: post.authorId }, {
fields: { username: 1, 'profile.avatar': 1 }
});
}
}]
};
});
Troubleshooting
Subscriptions Not Tracked
- Verify
trackSubscriptions: true - Check if subscription is in
ignoreSubscriptions - Ensure agent initializes before publications are defined
Inaccurate Document Counts
Document counts may not match exactly if:
- Documents are added/removed during the subscription lifecycle
- Multiple publications affect the same collection
Next Steps
- Error Tracking - Monitor subscription errors
- Dashboard Overview - Navigate subscription data
- Performance Optimization - Optimize slow subscriptions