Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/mywand/cusrsor-do-it/observabilitygit clone --depth 1 https://github.com/mywand/cusrsor-do-itWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00013 | $0.01732 |
| Opus 5 | $0.00006 | $0.00866 |
| Sonnet 5 | $0.00003 | $0.00346 |
| Haiku 4.5 | $0.00001 | $0.00173 |
Grade A, and why
observability scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 135 lines — stays where its author put it; the contents beside it link to each section on GitHub.
最近更新: 2025-09-18
Observability Guide
1. 目标 (Goals)
- 快速定位:问题发生 -> 5 分钟内能知道范围与根因候选。
- 量化健康:核心指标仪表板实时反映 SLA 状态。
- 可回放:关键业务路径具备足够上下文与追踪链路。
2. 三大支柱
| 支柱 | 作用 | 关键要素 |
|---|---|---|
| Logs | 定性分析 | 结构化 / 关键字段 / 采样策略 |
| Metrics | 定量趋势 | 标签维度 / 聚合 / 阈值报警 |
| Traces | 跨服务调用链 | span 层级 / 耗时 / 错误传播 |
3. 日志 (Logging)
- 结构化:JSON(字段:ts, level, traceId, spanId, userId, action, result, costMs, errorType)。
- 分类:访问日志 / 业务日志 / 安全审计 / 异常日志 分开存储或打标签。
- 采样:高 QPS 服务对 INFO 级别采样;错误级别全量。
- 隐私:脱敏(手机号中间脱敏,身份证仅后4位)。
4. 指标 (Metrics)
| 类型 | 示例 | 注意 |
|---|---|---|
| Counter | 请求总数 / 错误总数 | 仅递增,不回退 |
| Gauge | 当前队列长度 / 在线用户 | 快速波动可取平均 |
| Histogram | 请求耗时 / 载荷大小 | 设定合适 bucket |
| Summary | 自定义分位 | 不建议高并发全局使用 |
核心指标:
- 流量:QPS / 并发连接数
- 性能:p50/p95/p99 Latency
- 稳定性:Error Rate / Timeout Rate
- 资源:CPU / 内存 / GC / FD / 线程池使用率
- 容量:队列长度 / 缓存命中率 / DB 连接池耗尽次数
5. 追踪 (Tracing)
- 使用 OpenTelemetry:自动 + 手动埋点。
- 根 span:入口(HTTP / 消息 / 定时任务);子 span:外部调用 / DB / MQ。
- 上下文传递:traceparent / baggage。
- 大包/慢调用:记录 size / costMs 标签。
5.1 Span / Trace 命名约定
| 场景 | 命名模式 | 示例 |
|---|---|---|
| HTTP 入口 | http.. | http.GET.orders.list |
| RPC / 内部调用 | rpc.. | rpc.payment.refund |
| DB 查询 | db.. | db.postgres.select |
| 消息生产 | mq.produce. | mq.produce.order.created |
| 消息消费 | mq.consume. | mq.consume.order.created |
| 定时任务 / 批处理 | job. | job.settlement.rollup |
| 外部第三方 API | ext.. | ext.stripe.charge |
规则:
- 动词小写;资源名复数;不含动态 ID(放 attributes:
order.id=123)。 - 必要 attributes:
http.status_code,db.statement(摘要),peer.service,retry.count。 - 避免无语义名称(如
processTask)。名称应支持聚合统计与过滤。 - 入口 span 附加发布版本:
service.version;错误 span 标注error.type/error.message。 - Attributes 不放敏感数据(账号、密钥、PII)。
6. 事件 (Events)
- 业务事件(下单成功 / 支付失败)结构化发往事件总线供分析。
- 标准字段:eventId / eventType / occurredAt / version / payload。
7. 告警 (Alerting)
原则:只报警“需要人干预”的情况。
| 类别 | 例子 | 动作 |
|---|---|---|
| 可用性 | Error Rate > 阈值 | 立刻通知值班 & 降级 |
| 性能 | p99 > SLA * 1.5 持续 5 分钟 | 调整扩容/排查热点 |
| 资源 | CPU > 85% 持续 10 分钟 | 扩容 / 优化任务 |
| 安全 | 失败登录暴增 | 启动风控策略 |
| 数据 | 队列堆积超阈 | 清理/扩容/暂停上游 |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 135 lines · 13 tokens per session scan A ccb93c0831fc
observability is a cursor rule published in the GitHub repository mywand/cusrsor-do-it (2 stars, last pushed 7mo ago), licensed Apache-2.0. It adds 13 tokens to every session and 1,732 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.