SuperAPI AI 工具集

customerio-observability

部署与运维

查看项目

更新于 10-15 22:42

技能介绍

用途:为 Customer.io 集成建立完整的可观测性,输出有界指标与脱敏追踪,覆盖事件接收、活动投递、错误、延迟和限流余量,并提供投递、认证、数据质量与供应商事故的告警/运行手册路径。

主要能力:Prometheus 指标(API 延迟直方图、请求与错误计数、邮件发送/退信/投诉计数、Webhook 接收计数、队列深度仪表);结构化 JSON 日志(推荐 pino)并对邮箱、电话、IP、密码等字段脱敏;OpenTelemetry 追踪;Grafana 仪表盘定义;Prometheus 告警规则。

关键指标与阈值:cio_api_duration_ms(p99>5000ms)、cio_api_requests_total、cio_api_errors_total(错误率>1%)、cio_email_sent_total、cio_email_bounced_total(>5%)、cio_email_complained_total(>0.1%)、cio_webhook_received_total、cio_queue_depth(>10K)。

使用方式:用 prom-client 定义指标与 Registry;封装 InstrumentedCioClient 对 identify、track、sendEmail 计时并计数;用 pino 配置 redact 路径输出脱敏日志;在 Webhook 处理器中按 metric 类型累加计数;通过 Express 路由暴露 /metrics;导入 Grafana JSON 模型;加载 prometheus/customerio-alerts.yml 告警规则。

适用场景:已部署 Customer.io 集成、使用 Prometheus+Grafana 或兼容指标栈、需要结构化日志的团队。

限制与注意:指标标签避免使用 userId 等高基数维度,仅用 operation 与 status;生产环境可设 CUSTOMERIO_LOG_LEVEL=warn 控制日志量;需检查指标注册与抓取配置;确认 pino redact 覆盖全部敏感字段。前置条件为已部署 Customer.io 集成、Prometheus+Grafana、结构化日志系统。后续可进入 customerio-advanced-troubleshooting 排查。