agentleFS
andrueandersoncsandrueandersoncs/claude-skill-effect-ts/skills/observability/SKILL.md

Observability

Skill8 starsChanged 9 months agoMITView on GitHub

This skill should be used when the user asks about "Effect logging", "Effect.log", "Effect metrics", "Effect tracing", "spans", "telemetry", "Metric.counter", "Metric.gauge", "Metric.histogram", "OpenTelemetry", "structured logging", "log levels", "Effect.logDebug", "Effect.logInfo", "Effect.logWarning", "Effect.logError", or needs to understand how Effect handles logging, metrics, and distributed tracing.

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, ci-cd 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.
  • 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

  • JohnJBorenSkill

    ci-cd

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

    Also in 8 projects that use this

  • AnthropicSkill

    incident-response

    Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.

    Also in 16 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

  • terrene-foundationSkill

    architecture-decisions

    Architecture decision guides for Kailash SDK including framework selection (Core SDK vs DataFlow vs Nexus vs Kaizen), runtime selection (Async vs Sync), database selection (PostgreSQL vs SQLite), node selection, and test tier selection. Use when asking about 'which framework', 'choose framework', 'which runtime', 'which database', 'which node', 'architecture decision', 'when to use', 'Core SDK vs DataFlow', 'PostgreSQL vs SQLite', 'AsyncLocalRuntime vs LocalRuntime', or 'test tier selection'.

    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

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 42 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All three integrate seamlessly with Effect's execution model.

    line 17
  2. Distinctive:

    Use structured logging: - Add context via annotations

    line 316
  3. Distinctive:

    Name spans descriptively: - Use verb-noun format

    line 317
  4. Distinctive:

    Search for these sections:

    line 326

“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 in Effect

Overview

Effect provides built-in observability:

  • Logging - Structured, leveled logging
  • Metrics - Counters, gauges, histograms
  • Tracing - Distributed tracing with spans

All three integrate seamlessly with Effect's execution model.

Logging

Basic Logging

import { Effect } from "effect";

const program = Effect.gen(function* () {
  yield* Effect.log("Starting process");
  yield* Effect.logDebug("Debug information");
  yield* Effect.logInfo("Processing item");
  yield* Effect.logWarning("Resource running low");
  yield* Effect.logError("Failed to connect");
  yield* Effect.logFatal("Critical system failure");
});

Log Levels

import { LogLevel, Logger } from "effect";

// Set minimum log level
const filtered = program.pipe(Logger.withMinimumLogLevel(LogLevel.Info));

// Available levels (lowest to highest):
// Trace, Debug, Info, Warning, Error, Fatal, None

Structured Logging

// Log with structured data
yield *
  Effect.log("User action").pipe(
    Effect.annotateLogs({
      userId: "123",
      action: "login",
      ip: "192.168.1.1",
    }),
  );

// Annotations apply to all logs in scope
const program = Effect.gen(function* () {
  yield* Effect.log("First log"); // Has userId annotation
  yield* Effect.log("Second log"); // Has userId annotation
}).pipe(Effect.annotateLogs({ userId: "123" }));

Log Spans

// Add timing/context spans
const program = Effect.gen(function* () {
  yield* Effect.log("Processing");
  yield* processItems();
  yield* Effect.log("Complete");
}).pipe(Effect.withLogSpan("request-handler"));
// Logs include: [request-handler 45ms] Processing

Custom Logger

import { Logger } from "effect";

const JsonLogger = Logger.make(({ logLevel, message, annotations, date }) => {
  console.log(
    JSON.stringify({
      level: logLevel.label,
      message: String(message),
      timestamp: date.toISOString(),
      ...annotations,
    }),
  );
});

const program = Effect.gen(function* () {
  yield* Effect.log("Hello");
}).pipe(Effect.provide(Logger.replace(Logger.defaultLogger, JsonLogger)));

Metrics

Counter - Track Occurrences

import { Metric } from "effect";

const requestCount = Metric.counter("http_requests_total", {
  description: "Total HTTP requests",
});

const program = Effect.gen(function* () {
  yield* Metric.increment(requestCount);
  yield* Metric.incrementBy(requestCount, 5);
});

const tracked = handleRequest.pipe(Metric.trackAll(requestCount));

Gauge - Track Current Value

const activeConnections = Metric.gauge("active_connections", {
  description: "Current active connections",
});

const program = Effect.gen(function* () {
  yield* Metric.set(activeConnections, 10);
  yield* Metric.incrementBy(activeConnections, 1);
  yield* Metric.decrementBy(activeConnections, 1);
});

Histogram - Track Distributions

const requestDuration = Metric.histogram("http_request_duration_ms", {
  description: "Request duration in milliseconds",
  boundaries: [10, 50, 100, 250, 500, 1000],
});

yield * Metric.observe(requestDuration, 125);

const tracked = handleRequest.pipe(Metric.trackDuration(requestDuration));

Summary - Statistical Summary

const responseSizes = Metric.summary("response_size_bytes", {
  description: "Response payload sizes",
  maxAge: "1 minute",
  maxSize: 100,
  quantiles: [0.5, 0.9, 0.99],
});

yield * Metric.observe(responseSizes, 1024);

Frequency - Count by Tag

const statusCodes = Metric.frequency("http_status_codes");

yield * Metric.observe(statusCodes, "200");
yield * Metric.observe(statusCodes, "404");
yield * Metric.observe(statusCodes, "500");

Tagged Metrics

const requestCount = Metric.counter("requests").pipe(Metric.tagged("service", "api"), Metric.tagged("version", "v1"));

// Dynamic tags
const taggedCount = Metric.counter("requests").pipe(Metric.taggedWithLabels(["method", "endpoint"]));

yield * Metric.increment(taggedCount).pipe(Metric.taggedWithLabels(["GET", "/users"]));

Reading Metrics

const program = Effect.gen(function* () {
  yield* Metric.increment(requestCount);
  yield* Metric.increment(requestCount);

  const snapshot = yield* Metric.value(requestCount);
  // snapshot.count === 2
});

Tracing

Creating Spans

import { Effect } from "effect";

const traced = handleRequest.pipe(Effect.withSpan("handle-request"));

const traced = handleRequest.pipe(
  Effect.withSpan("handle-request", {
    attributes: {
      "http.method": "GET",
      "http.url": "/api/users",
    },
  }),
);

Nested Spans

const program = Effect.gen(function* () {
  yield* fetchUser(id).pipe(Effect.withSpan("fetch-user"));
  yield* processData(data).pipe(Effect.withSpan("process-data"));
  yield* saveResult(result).pipe(Effect.withSpan("save-result"));
}).pipe(Effect.withSpan("main-operation"));
// Creates: main-operation
//            ├── fetch-user
//            ├── process-data
//            └── save-result

Adding Span Attributes

import { Tracer } from "effect";

const program = Effect.gen(function* () {
  yield* Effect.annotateCurrentSpan("user.id", userId);

  yield* Effect.annotateCurrentSpan("event", "user_validated");

  const result = yield* processUser(userId);

  yield* Effect.annotateCurrentSpan("result.status", result.status);
});

Span Status

const program = Effect.gen(function* () {
  try {
    return yield* riskyOperation;
  } catch (error) {
    yield* Effect.setSpanStatus({
      code: "error",
      message: error.message,
    });
    return yield* Effect.fail(error);
  }
}).pipe(Effect.withSpan("risky-operation"));

Custom Tracer

import { Tracer } from "effect";

const ConsoleTracer = Tracer.make({
  span: (name, parent, context, links, startTime) => ({
    attribute: (key, value) => console.log(`[${name}] ${key}=${value}`),
    end: (endTime, exit) => console.log(`[${name}] ended`),
    event: (name, startTime, attributes) => console.log(`[${name}] event: ${name}`),
    status: (status) => console.log(`[${name}] status: ${status.code}`),
  }),
});

const program = myEffect.pipe(Effect.provide(Tracer.layer(ConsoleTracer)));

OpenTelemetry Integration

import { NodeSdk } from "@effect/opentelemetry";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";

const TracingLive = NodeSdk.layer(() => ({
  resource: { serviceName: "my-service" },
  spanProcessor: new BatchSpanProcessor(new OTLPTraceExporter()),
}));

const program = myEffect.pipe(Effect.provide(TracingLive));

Combining Observability

const handleRequest = (req: Request) =>
  Effect.gen(function* () {
    yield* Effect.log("Request received").pipe(Effect.annotateLogs({ path: req.path, method: req.method }));

    yield* Metric.increment(requestCount);

    const result = yield* processRequest(req);

    yield* Effect.annotateCurrentSpan("response.status", result.status);
    yield* Metric.observe(requestDuration, result.duration);

    return result;
  }).pipe(
    Effect.withSpan("handle-request", {
      attributes: {
        "http.method": req.method,
        "http.url": req.path,
      },
    }),
  );

Best Practices

  1. Use structured logging - Add context via annotations
  2. Name spans descriptively - Use verb-noun format
  3. Add meaningful attributes - Enable debugging/analysis
  4. Track key metrics - Request count, latency, errors
  5. Use appropriate log levels - Debug in dev, Info in prod

Additional Resources

For comprehensive observability documentation, consult ${CLAUDE_PLUGIN_ROOT}/references/llms-full.txt.

Search for these sections:

  • "Built-in Logging" for logging APIs
  • "Metrics" for metric types
  • "Tracing" for distributed tracing

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.