agentleFS
DeadlymindDeadlymind/nanolama/skills/observability/SKILL.md

observability

Skill1 starsChanged 5 months agoMITView on GitHub

Instruments a Django/DRF plus Celery plus Channels stack so production failures are visible — structured JSON logs carrying a correlation id, tenant id (entreprise) and user id on every line, that same id propagated across the request, the task it enqueues and any consumer, plus tracing spans on state-changing work, scrubbed error tracking, and RED metrics with alerts that page a human. Use when adding logging or a logging filter, threading a correlation id through Celery or Channels, wiring an error tracker or metrics dashboard, or asking how to make one user action one traceable thread. Not for triaging a live incident (see incident-response) or auditing a diff for leaks (see security-review).

59 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use parallel-agent-orchestration, caching and 6 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.
  • itallstartedwithaideaSkill

    parallel-agent-orchestration

    Parallel Agent Orchestration is the discipline of dispatching, coordinating, and aggregating results from multiple concurrent subagents to dramatically accelerate complex tasks.

    Also in 3 projects that use this

  • zebbernSkill

    caching

    Caching strategies — invalidation, TTL guidelines, cache keys, cache layers, and when not to cache. Use when implementing or reviewing caching logic.

    Also in 3 projects that use this

  • mmondoraSkill

    finops

    Cloud cost management as an architectural discipline. Unit economics, right-sizing, GCP free tier optimization, budget alerts, serverless-first. Use when making infrastructure decisions, estimating costs, or optimizing cloud spending.

    Also in 3 projects that use this

  • cryptofish7Skill

    ci-cd-pipeline

    Analyze a repo and maintain its GitHub Actions CI/CD pipeline. Detects language, tooling, test frameworks, Docker, and deploy targets, then adds or removes workflow actions to match the project's current state. Use when the user asks to "add CI/CD", "update CI", "review pipeline", "set up GitHub Actions", "audit CI", "improve CI/CD", or any request about CI/CD pipelines, GitHub Actions workflows, or continuous integration.

    Also in 3 projects that use this

  • korchard333Skill

    data-migration

    Data migration to and within Dataverse. Use when: data migration, data import, bulk load, CSV import, legacy CRM migration, data quality, deduplication, staging tables, KingswaySoft, Azure Data Factory, dataflows, Web API bulk, entity mapping.

    Also in 3 projects that use this

  • rohitg00Skill

    ci-cd-pipelines

    CI/CD pipeline patterns for GitHub Actions, GitLab CI, testing strategies, and deployment automation

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 42 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Absolute rule: never log a secret, token, cookie, Authorization header, or raw PII.

    line 32
  2. Distinctive:

    A dashboard nobody watches is not monitoring: If a signal has no threshold that pages, treat it as decoration — the outage will be found by …

    line 99
  3. Very specific:

    High-cardinality metric labels explode cost: Never label a metric with user_id or a raw id.

    line 101
  4. Distinctive:

    Don't rebuild an id that already exists: If an upstream proxy or gateway already sets a request/trace id, adopt it instead of minting a …

    line 103

“Common” is measured: kept by at least 6 in 10 of the 42 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

Observability (tenant-correlated logs, traces, metrics)

When to use

Adding or reviewing anything that must be debuggable in production without a repro: a new logging config, a Celery task or Channels consumer whose failures you can't currently trace, an error-tracker integration, or a metrics dashboard. The goal is that one user action reads as one traceable thread across the web request, the background task it fires, and any realtime consumer — all stamped with who (user) and which tenant (entreprise).

Pattern

Four signals, one correlation id tying them together:

  1. Structured logs. Emit JSON, not free text. Every line carries a correlation_id, entreprise_id, and user_id — injected by a logging filter, never hand-passed. Grep-by-tenant and grep-by-request both work.
  2. Propagated correlation id. Generate (or accept) the id at the DRF request edge, put it in a context var, and pass it explicitly into every Celery task and Channels consumer that request spawns. Background work inherits the thread.
  3. Distributed tracing. Open a span (OpenTelemetry-style) around every state-changing action and every background task, so you can see the request → task → consumer causal chain and where the latency lives.
  4. Metrics with alerts. Track the RED signals — request Rate, Error rate, Duration — plus queue depth and live websocket-connection counts, and set thresholds that page a human, not just color a chart.

Absolute rule: never log a secret, token, cookie, Authorization header, or raw PII. Scrub before the record leaves the process. This is a security boundary, not a nicety (ties security-review).

Steps / idioms

  1. Stamp every log line via a filter. A logging.Filter reads the current request's context and attaches the ids to each record, so no call site has to remember. Point a JSON formatter at the same fields:

    # observability/logging.py — inject correlation + tenant into every record.
    import logging
    from contextvars import ContextVar
    
    correlation_id: ContextVar[str] = ContextVar("correlation_id", default="-")
    entreprise_id:  ContextVar[str] = ContextVar("entreprise_id",  default="-")
    user_id:        ContextVar[str] = ContextVar("user_id",        default="-")
    
    class ContextFilter(logging.Filter):
        def filter(self, record: logging.LogRecord) -> bool:
            record.correlation_id = correlation_id.get()
            record.entreprise_id  = entreprise_id.get()
            record.user_id        = user_id.get()
            return True  # filter only enriches; it never drops the record

    Set the context vars in DRF middleware from request.user (reuse the same tenant accessor as multi-tenancy); read an inbound X-Correlation-ID header if present, else mint a UUID and echo it back on the response.

  2. Carry the id into background work. Context vars do not cross a process, so pass the id as an explicit task argument (or a header) and re-set it at the top of the task; do the same in a Channels consumer's connect:

    # Enqueue with the id; the worker re-establishes context on receipt.
    process_invoice.delay(invoice_id, correlation_id=correlation_id.get())
  3. Wrap state-changing work in a span. Name it for the action (invoice.approve), tag it with entreprise_id, and let the task span link to the request span via the propagated id. Read-only GETs rarely need their own.
  4. Scrub before export. Configure the error tracker's before-send hook to drop Authorization/Cookie headers, password/token/secret keys, and known PII fields — allowlist what may leave, don't blocklist and hope.
  5. Wire alerts, not just dashboards. An error-rate spike, a growing Celery queue, or a websocket-connection cliff should page on-call (see incident-response for what happens after the page).

Adapt to your repo

Rename entreprise_id/Entreprise and the tenant/user accessor path to match your models. Choose your own transport for the correlation id into Celery (task kwarg vs. message header) and Channels (scope entry). Do not pin tool versions here — Sentry, OpenTelemetry, and your metrics backend all move; confirm the current SDK and API surface with version-check before wiring. The stable facts you can rely on are the RED signal set and the correlation-id discipline, not any one vendor's helper names.

Gotchas

  • Context vars are per-process, per-task. A .delay() does not carry your ContextVar — pass the id explicitly and re-set it in the worker, or the task's logs show correlation_id=- and the thread breaks exactly where you need it.
  • Logging the request body re-leaks what the serializer hid. A debug line that dumps request.data can spill a token or PII the API response never exposed — scrub at the logging boundary too, not only at the API edge (security-review).
  • Sampling hides the rare error. Trace-sample normal traffic if you must, but keep error traces at 100% or the one failure you're chasing gets dropped.
  • A dashboard nobody watches is not monitoring. If a signal has no threshold that pages, treat it as decoration — the outage will be found by a customer.
  • High-cardinality metric labels explode cost. Never label a metric with user_id or a raw id; keep entreprise_id for logs/traces, aggregate metrics.
  • Don't rebuild an id that already exists. If an upstream proxy or gateway already sets a request/trace id, adopt it instead of minting a competing one.

See also

  • incident-response
  • security-review
  • celery-tasks
  • deploy-aws

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.