agentleFS
subhash-arabhisubhash-arabhi/saas-playbook/skills/observability-and-instrumentation/SKILL.md

observability-and-instrumentation

Skill1 starsChanged 31 days agoMITView on GitHub

Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing or alerting; when shipping a feature, endpoint, background job or integration that runs in production; or when an incident couldn't be diagnosed from the available data. Not for debugging a live failure (use debugging-and-error-recovery).

49 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use constraint-driven-development, performance-optimization and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MrCipherSmithSkill

    constraint-driven-development

    Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.

    Also in 17 projects that use this

  • barisariburnuSkill

    performance-optimization

    Complete performance optimization guide for Next.js applications including frontend, backend, database, caching, and general optimization strategies. Use when improving performance, reducing bundle size, optimizing queries, or implementing caching.

    Also in 31 projects that use this

  • silvainfmSkill

    marketing-ideas

    When the user needs marketing ideas, inspiration, or strategies for their SaaS or software product. Also use when the user asks for 'marketing ideas,' 'growth ideas,' 'how to market,' 'marketing strategies,' 'marketing tactics,' 'ways to promote,' or 'ideas to grow.' This skill provides 140 proven marketing approaches organized by category.

    Also in 4 projects that use this

  • CloudflareSkill

    receiving-code-review

    Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation

    Also in 5 projects that use this

  • IgorGanapolskySkill

    graphify

    Query the local Graphify-Labs AST knowledge graph for ThumbGate architecture questions (what connects X to Y, explain a symbol, PreToolUse/gates/adapters). Slash: /graphify.

    Also in 4 projects that use this

  • GoogleSkill

    ponytail

    Forces the laziest solution that actually works, simplest, shortest, most minimal. Channels a senior dev who has seen everything: question whether the task needs to exist at all (YAGNI), reach for the standard library before custom code, native platform features before dependencies, one line before fifty. Supports intensity levels: lite, full (default), ultra. Use on ANY coding task: writing, adding, refactoring, fixing, reviewing, or designing code, and choosing libraries or dependencies. Also use whenever the user says "ponytail", "be lazy", "lazy mode", "simplest solution", "minimal solution", "yagni", "do less", or "shortest path", or complains about over-engineering, bloat, boilerplate, or unnecessary dependencies. Do NOT use for non-coding requests (general knowledge, prose, translation, summaries, recipes).

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 45 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Project rules first: If the project has .agents/rules/ (installed with the SaaS playbook), read .agents/rules/deployment.md and …

    line 8
  2. Very specific:

    Write telemetry with the feature, like tests.

    line 12
  3. Distinctive:

    Before instrumenting, write 2–4 questions whoever runs the feature will ask when it seems broken (e.g.

    line 25
  4. Very specific:

    Add custom metrics only for business questions (e.g.

    line 41
  5. Very specific:

    Add manual spans only around meaningful internal work (e.g.

    line 47
  6. Distinctive:

    Every alert is actionable (if the answer is "ignore it, it self-heals", delete it), has a runbook entry, and has a threshold and duration …

    line 54
  7. Distinctive:

    Follow one request from website through API in the trace view, with no broken spans.

    line 62

“Common” is measured: kept by at least 6 in 10 of the 45 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- Adapted from addyosmani/agent-skills@1401c8b (MIT, see licenses/). Changes: layered (general guidance here, playbook decisions in .agents/rules/); cloud-agnostic; one monitoring service for API + website via OpenTelemetry, request ID across website→API, two alert severities, a runbook entry per alert, cost controls, language-agnostic; trimmed (examples in references/). -->

Project rules first. If the project has .agents/rules/ (installed with the SaaS playbook), read .agents/rules/deployment.md and .agents/rules/security.md and follow them: they override this skill where they differ. Without them, follow this skill as written.

Observability and Instrumentation

Write telemetry with the feature, like tests. For worked examples (log lines, entry-point logging, OpenTelemetry setup, metric labels, alert choices, runbook entry), read references/observability-patterns.md.

Baseline setup

  • API: OpenTelemetry logs, metrics and traces, exported to one monitoring service.
  • Website: a browser SDK (the service's own or OpenTelemetry web) sending errors and page performance to the same service.
  • Website ↔ API: the website sends W3C trace context (traceparent); the API returns the ID in an x-request-id header. One request is followable from browser to API to database.
  • A browser SDK's ingestion key is usually not a secret and may sit in public config (check the service's docs). Every other secret rule still applies.
  • In the browser SDK, turn off personal data collection: no user IP storage, no automatic form-value capture, no cookies unless consent rules allow them.
  • Cost: set a daily ingestion cap; sample successful requests but keep 100% of errors; debug logging off in production.

Process

1. Write the questions first

Before instrumenting, write 2–4 questions whoever runs the feature will ask when it seems broken (e.g. "Why do payments fail permanently?"). Every signal you add must answer one of them.

2. Pick the signal

  • Metric: how often / how fast in aggregate (tells you that something is wrong).
  • Trace: where time went across services (where).
  • Structured log: what happened in one case (why).

3. Structured logging

  • Log events, not prose: a stable event name plus structured fields (log.warn("payment_failed", {paymentId, errorCode, attempt})). Never build log lines by string concatenation.
  • Levels: error = invariant broken, someone may need to act; warn = degraded but handled (retry, fallback); info = significant business event; debug = diagnostic, off in production.
  • Correlation ID on every line. Accept incoming trace context (or create it) at the API boundary, attach it to every log line and span, pass it on every outbound call and queue message, and return it to the caller.
  • When several entry points (scheduler, replay endpoint, CLI) write one log, stamp an entryPoint field where the run starts and propagate it with the correlation ID across the same boundaries. Use entryPoint, not source (reserved for network fields).
  • Never log secrets, tokens, passwords or full personal data. Allowlist the logged fields; never log whole request bodies.

4. Metrics

  • RED (rate, errors, duration) for every endpoint and outside dependency; USE (utilization, saturation, errors) for resources like queues and pools. OpenTelemetry auto-instrumentation covers RED for endpoints and outbound calls.
  • Add custom metrics only for business questions (e.g. payments_retried), as counters or histograms.
  • Labels come from small fixed sets (route template, status class 5xx, provider). Never user IDs, emails, request IDs, raw URLs or error text: those go in logs and traces.
  • Latency is a histogram read as p50/p95/p99. Never track averages.

5. Tracing

  • Configure OpenTelemetry at API startup, before anything else loads: service name, exporter config from the secret store or env, auto-instrumented HTTP server, HTTP client and database client, sampling (fraction of successes, all errors).
  • Add manual spans only around meaningful internal work (e.g. charge_provider), with the attributes you'll filter by.
  • Propagate context across every async boundary (HTTP headers, queue metadata), or the trace stops there.
  • With one origin (API under /api), browser trace headers reach the API without CORS setup.

6. Alerting

  • Alert on symptoms users feel (error rate, latency, failing health check, queue age, website JS error spike), not causes (CPU, a restart, disk). Causes go on dashboards.
  • Every project has at least: an availability test on the health endpoint (e.g. /api/health) and the homepage, through the public URL, from a few regions; an API error-rate alert; an API p95/p99 latency alert.
  • Every alert is actionable (if the answer is "ignore it, it self-heals", delete it), has a runbook entry, and has a threshold and duration based on data or on what users would notice.
  • Two severities only: notify me now (user-facing, act now; an interrupting channel like mobile push) and show me later (degradation, act this week; a channel read daily like email). No third tier.
  • Runbook entry per alert, kept with the project docs (e.g. a "Monitoring and alerts" section in the architecture doc): what is happening, what to check first, how to fix or roll back. Keep it short; add steps only when the first check isn't enough. When an entry proves wrong in an incident, fix it with the next commit.

7. Verify the telemetry before production

Locally (or in staging), trigger the paths and look at real output:

  • Force an error, find it by request ID, and confirm the fields are structured (no [object Object]) and contain no secrets or personal data.
  • Send test traffic; confirm metrics appear with the expected labels and sane values.
  • Follow one request from website through API in the trace view, with no broken spans.
  • Fire each new alert once (temporarily lower the threshold); confirm it arrives on its channel and its runbook entry exists.
  • Locate an induced failure from telemetry alone, without reading the source.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.