agentleFS
lbdremylbdremy/phax/.claude/skills/observability/SKILL.md

observability

Skill2 starsChanged 5 months agoApache-2.0View on GitHub

Wire OpenTelemetry through the SystemTelemetry port — domain produces semantic spans, infra transports them — never bypass the port in app/ or cli/.

89 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use gitops, background-jobs and 10 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.
  • kcns008Skill

    gitops

    GitOps Agent (Flow) — manages ArgoCD applications, Helm charts, Kustomize overlays, deployment strategies (canary, blue-green, rolling), multi-cluster GitOps, and drift detection for Kubernetes and OpenShift clusters.

    Also in 4 projects that use this

  • YepAPISkill

    background-jobs

    Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

    Also in 4 projects that use this

  • Mushfiqur-Rahman-RobinSkill

    rag-systems

    Best practices for building Retrieval-Augmented Generation systems — chunking, embedding, hybrid retrieval, reranking, indexing, caching, evaluation, observability — plus a catalog of RAG patterns and when each applies.

    Also in 3 projects that use this

  • YepAPISkill

    data-pipelines

    ETL patterns, cron scheduling, queue-based processing, and batch jobs with Inngest/BullMQ.

    Also in 4 projects that use this

  • wpankSkill

    caching

    Caching strategies, invalidation, eviction policies, HTTP caching, distributed caching, and anti-patterns. Use when designing cache layers, choosing eviction policies, debugging stale data, or optimizing read-heavy workloads.

    Also in 5 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 13 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 72 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    Never call @opentelemetry/* APIs from src/app/ or src/cli/.

    line 36

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

Core principle: OpenTelemetry transports and correlates. The system produces the meaning. Snapshots capture the meaning, not the transport.

Three-layer split

src/domain/telemetry/   ← pure semantic types, NO Effect, NO OTel, NO IO
src/ports/systemTelemetry.ts  ← Effect service (Context.Tag) — the app talks here
src/infra/telemetry/    ← implementations (OTel, file, in-memory, composite)
LayerRule
domain/May not import SystemTelemetry port, infra/telemetry, or @opentelemetry/*
app/Calls SystemTelemetry only; must not import infra/telemetry/_ or @opentelemetry/_
cli/May use the factory (layer.ts) at the composition root; must not import the OTel adapter or @opentelemetry/* directly
infra/telemetry/Only module that may import @opentelemetry/*

SystemTelemetry port (src/ports/systemTelemetry.ts)

MethodWhen to call
withOperation(name, attrs, eff)Wrap any named unit of work — becomes a span in OTel
recordEvent(event)Emit a SemanticTelemetryEvent (adapter call, step, gate, artifact)
recordTransition(transition)Shortcut for state.transition events from the dispatcher
recordError(report)Emit a SystemErrorReport when an adapter boundary fails
incrementCounter(name, attrs?)Increment a named metric counter
recordDuration(name, ms, attrs?)Record a duration sample

Never call @opentelemetry/* APIs from src/app/ or src/cli/.

Implementations (src/infra/telemetry/)

FilePurpose
inMemory.tsCollects events in-process; used in tests via getSemanticTraceSnapshot()
jsonFile.tsAppends one JSON line per event to a configurable path; IO errors swallowed
openTelemetry.tsMaps semantic events onto OTel spans/events/metrics; only file that imports @opentelemetry/*
composite.tsFans out one logical call to multiple implementations; inner failures swallowed
layer.tsFactory (makeSystemTelemetryLayer) — called by src/cli/ to build the live layer

Fake for tests: src/infra/fakes/systemTelemetry.ts → makeFakeSystemTelemetry().

Snapshot rule

Tests assert against InMemoryTelemetry.getSemanticTraceSnapshot(), which projects events through projectEvent from src/domain/telemetry/snapshot.ts.

Snapshots must never contain: traceId, spanId, durationMs, or any 13+ digit Unix timestamp. Only semantic fields survive projection: type, event, stateBefore, stateAfter, dispatcher, operationId, adapter, operation, result, step, gate, artifact, path.

E2E helper: import withTelemetryCapture from tests/e2e/helpers/telemetry.ts.

SystemErrorReport contract

Built at the application layer (not inside infra adapters) using makeSystemErrorReport from src/domain/telemetry/errors.ts. Report builders live in src/app/telemetry/reportBuilders.ts:

  • reportShellFailure(e, ctx) — Shell adapter failures
  • reportGitFailure(e, ctx) — Git adapter failures
  • reportAgentFailure(e, ctx) — Agent backend adapter failures

stderrExcerpt is always truncated to ≤ 4 KB by makeSystemErrorReport.

Architectural guards (tests/unit/architecturalGuards.telemetry.test.ts)

RuleWhat it checks
PHAX_TELEMETRY_001src/domain/ has no forbidden imports (port, infra, OTel)
PHAX_TELEMETRY_002Only src/infra/telemetry/openTelemetry.ts and its unit test import @opentelemetry/*
PHAX_TELEMETRY_003src/app/ has no infra/telemetry imports; src/cli/ has no direct OTel adapter imports
PHAX_TELEMETRY_004Snapshot files contain no transport fields or raw Unix timestamps

How to fix a violation

PHAX_TELEMETRY_001: The domain file is importing a port or adapter. Move the type it needs into src/domain/telemetry/ or pass it as a plain value parameter.

PHAX_TELEMETRY_002: An unexpected file imports OTel. Route telemetry through SystemTelemetry port instead. If this is a new OTel adapter, it belongs in src/infra/telemetry/ and must be added to the guard allowlist.

PHAX_TELEMETRY_003: An app file is importing a concrete adapter. Use the SystemTelemetry port via Effect DI. A CLI file importing the OTel adapter directly must go through makeSystemTelemetryLayer instead.

PHAX_TELEMETRY_004: A snapshot was captured before getSemanticTraceSnapshot() was applied, or a new unstable field leaked into the projection. Always snapshot the projection output, never the raw event or OTel span.

Further reading

  • Doctrine source: .context/attachments/rK8ZI3/pasted_text_2026-05-25_14-05-46.txt
  • Architecture docs: docs/observability.md (added in phase-12)
  • Snapshot baseline: tests/e2e/__snapshots__/semanticTrace.test.ts.snap

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.