Twilio
patrol.Twilio sends one message per project in the batch, to a single recipient. The body is rendered from patrol.TwilioTemplate, an exported text/template: message, type, capture time, the fields, and the stacktrace frames.
SMS or WhatsApp is not an option field. It is decided by the numbers: prefix both FromNumber and ToNumber with whatsapp: and the message goes over WhatsApp. Prefix one and not the other and it stays an SMS attempt, which Twilio will reject.
The constructor
Section titled “The constructor”patrol.NewTwilio(opts patrol.TwilioOptions) (*patrol.Twilio, error)All four of AccountSID, AuthToken, FromNumber and ToNumber are required, in one error. TimeZone is loaded here too.
Options
Section titled “Options”| Field | Type | JSON | YAML and TOML | Required |
|---|---|---|---|---|
AccountSID |
string |
account_sid |
AccountSID |
yes |
AuthToken |
string |
auth_token |
AuthToken |
yes |
FromNumber |
string |
from_number |
FromNumber |
yes |
ToNumber |
string |
to_number |
ToNumber |
yes |
TimeZone |
string |
time_zone |
TimeZone |
no |
One recipient per flusher. Two people on call means two patrol.Twilio values passed to the same producer, which is fine: flushers are independent and both get the batch.
AccountSID:AuthToken:FromNumber: whatsapp:+...ToNumber: whatsapp:+...TimeZone: Europe/AthensWhat Test does
Section titled “What Test does”producer.Test(ctx) lists one active account through the Twilio API and fails when the credentials are wrong or no account comes back. It does not check that the numbers are valid or that the WhatsApp sender is approved.
A worked example
Section titled “A worked example”From _examples/basic/program:
// source: _examples/basic/program/main.go#L68-L73 // WhatsApp (or SMS) through Twilio. twilioFlusher, err := patrol.NewTwilio(readConfig[patrol.TwilioOptions]("whatsapp.yml")) if err != nil { log.Fatal(err) } eventFlushers = append(eventFlushers, twilioFlusher)Gotchas
Section titled “Gotchas”This flusher ignores the context. twilio-go offers no context-aware call for sending a message or listing an account, so FlushEvents and Test take the context and do not use it. A deadline on producer.Close(ctx) or a ConsumeTimeout on a Server will not interrupt a Twilio call in flight: the shutdown returns, and the call finishes on its own schedule. The library carries a TODO on this, waiting for the upstream API.
Every message costs money, and stacktraces are long. An SMS is billed per 160-character segment, and one event with a stacktrace is thousands of characters. Send Twilio the events that are worth waking someone for, not the whole batch. Two ways to do that: give the Twilio flusher its own producer and only send it what matters, or put it behind a wrapper that filters the batch before calling through.
One message per project. Two project names in one batch is two messages, and several segments each.
No files and no mentions. Both are ignored here.