Overview
@kubiks/otel-resend provides OpenTelemetry instrumentation for the Resend email service Node.js SDK. Capture spans for every email operation with detailed metadata about recipients, subjects, and delivery status.

Visualize your email operations with detailed span information including recipients, subject lines, and delivery status—without capturing sensitive email content.
Installation
Quick Start
What Gets Traced
This instrumentation specifically wraps theresend.emails.send method (and its alias resend.emails.create), creating a single clean span for each email send operation.
Only metadata is captured—email content (HTML, text, attachments) is never included in traces for privacy and security.
Span Attributes
Each span includes rich metadata about the email operation:Usage Examples
Basic Email
With CC and BCC
BCC addresses are included in the span but remain hidden from other recipients as expected.
Using Email Templates
With Attachments
Transactional Emails
Complete Integration Example
Here’s a complete example of Resend with OpenTelemetry in a Next.js application:lib/resend.ts
lib/email.ts
app/api/auth/signup/route.ts
app/actions/email.ts
Best Practices
Use Environment Variables
Use Environment Variables
Always store API keys in environment variables:Never commit API keys to version control.
Handle Errors Gracefully
Handle Errors Gracefully
Always check for errors when sending emails:
Use Verified Domains
Use Verified Domains
Set up domain verification in Resend for production:
Implement Rate Limiting
Implement Rate Limiting
Be mindful of Resend rate limits and implement appropriate rate limiting:
Use Email Templates
Use Email Templates
Use React Email or Resend templates for maintainable email content:
Troubleshooting
Spans Not Appearing
Spans Not Appearing
Ensure OpenTelemetry is properly configured:
Missing Message ID
Missing Message ID
The message ID is only available after successful email sending. Check for errors:
Emails Not Delivering
Emails Not Delivering
Check your Resend dashboard for delivery status. Common issues:
- Domain not verified
- Invalid recipient address
- Rate limits exceeded
- API key issues
Integration with React Email
Resources
Resend Documentation
Learn more about Resend
GitHub Repository
View source code and examples
npm Package
View package on npm
React Email
Build emails with React components