SMTP: Add metrics#96
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Prometheus instrumentation to the SMTP server (per-session counters, gauges, histograms for bytes, commands, replies, messages, errors and session duration) and to the IC delivery agent (canister-id lookup and IC SMTP request metrics). Also adds a message_id field to the Candid SmtpRequest, lowers the default max message size to fit IC limits, and adds two small reusable helpers (IpFamily, BoolYesNo).
Changes:
- New
Metricstypes insmtp::modandsmtp::ic, plumbed throughServer,SessionManager,Session, andIcSmtpDeliveryAgent. - Recording of bytes/commands/replies/protocol errors/session lifecycle in inbound SMTP, and canister-id lookup + per-request latency in the IC delivery agent.
- Candid protocol gains
message_id: Option<String>and delivery now usesjoin_allso all canisters are observed even when some fail.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ic-bn-lib/src/lib.rs | Adds IpFamily and BoolYesNo helper traits used by new metric label code. |
| ic-bn-lib/src/smtp/mod.rs | Defines inbound SMTP Metrics struct and derives IntoStaticStr on error enums for labels. |
| ic-bn-lib/src/smtp/cli.rs | Lowers default max message size to 1950KB to fit IC message limits. |
| ic-bn-lib/src/smtp/server.rs | Threads Metrics through Server::new/new_with_listener into sessions. |
| ic-bn-lib/src/smtp/inbound/mod.rs | Adds labels/metrics to Session, moves shutdown here, adds protocol-error/message metric updates and a request_str helper. |
| ic-bn-lib/src/smtp/inbound/session.rs | Records bytes_tx/bytes_rx, replies, and per-command counters in the state machine. |
| ic-bn-lib/src/smtp/inbound/manager.rs | Records open/processed sessions and durations, including a partial path on TLS handshake failure. |
| ic-bn-lib/src/smtp/inbound/tests.rs | Updates test call sites for new Metrics parameter. |
| ic-bn-lib/src/smtp/ic/mod.rs | Defines IC delivery Metrics struct (lookups + request latencies). |
| ic-bn-lib/src/smtp/ic/delivery_agent.rs | Threads Metrics through, switches to join_all, records canister-id lookup and SMTP request metrics, adds message_id to requests. |
| ic-bn-lib/src/smtp/ic/candid.rs | Adds message_id: Option<String> to SmtpRequest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frankdavid
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds Prometheus metrics to SMTP server & IC Delivery Agent.
Also adds
message_idfield to the Candid protocol.