Skip to main content

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.
Resend Trace Visualization
Visualize your email operations with detailed span information including recipients, subject lines, and delivery status—without capturing sensitive email content.

Installation

Peer Dependencies: @opentelemetry/api >= 1.9.0, resend >= 3.0.0

Quick Start

instrumentResend wraps the instance you already use—no configuration changes needed. Every SDK call creates a client span with useful attributes.

What Gets Traced

This instrumentation specifically wraps the resend.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:
The instrumentation captures email addresses and metadata to help with debugging and monitoring, while avoiding sensitive email content.

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

Always store API keys in environment variables:
Never commit API keys to version control.
Always check for errors when sending emails:
Set up domain verification in Resend for production:
Be mindful of Resend rate limits and implement appropriate rate limiting:
Use React Email or Resend templates for maintainable email content:

Troubleshooting

Ensure OpenTelemetry is properly configured:
The message ID is only available after successful email sending. Check for errors:
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

License

MIT