Skip to content

SMTP: Add metrics#96

Merged
blind-oracle merged 5 commits into
mainfrom
igor/smtp-metrics
Jun 3, 2026
Merged

SMTP: Add metrics#96
blind-oracle merged 5 commits into
mainfrom
igor/smtp-metrics

Conversation

@blind-oracle

Copy link
Copy Markdown
Contributor

This adds Prometheus metrics to SMTP server & IC Delivery Agent.
Also adds message_id field to the Candid protocol.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Metrics types in smtp::mod and smtp::ic, plumbed through Server, SessionManager, Session, and IcSmtpDeliveryAgent.
  • 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 uses join_all so 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.

Comment thread ic-bn-lib/src/smtp/ic/delivery_agent.rs Outdated
Comment thread ic-bn-lib/src/smtp/ic/delivery_agent.rs Outdated
Comment thread ic-bn-lib/src/smtp/inbound/manager.rs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@blind-oracle blind-oracle marked this pull request as ready for review June 2, 2026 12:49
@blind-oracle blind-oracle requested a review from a team as a code owner June 2, 2026 12:49
Comment thread ic-bn-lib/src/smtp/ic/delivery_agent.rs Outdated
Comment thread ic-bn-lib/src/smtp/ic/delivery_agent.rs
Comment thread ic-bn-lib/src/smtp/ic/candid.rs
@blind-oracle blind-oracle merged commit bc159ad into main Jun 3, 2026
6 checks passed
@blind-oracle blind-oracle deleted the igor/smtp-metrics branch June 3, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants