Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
itallstartedwithaidea avatar

Observability

  • 54 installs
  • 31 repo stars
  • Updated April 12, 2026
  • itallstartedwithaidea/agent-skills

Instrument Cloudflare Workers and edge apps with structured logs, traces, and error alerts so you can debug production without traditional APM agents.

About

Observability is an agent skill for solo builders shipping on Cloudflare Workers and other edge runtimes where there is no long-lived process, log directory, or sidecar APM. It walks your agent through the three pillars—structured logging as JSON events with correlation IDs, distributed tracing with request-scoped spans, and monitoring with error rates, latency percentiles, and alerting rules—so you can answer what happened, how long it took, and how often it fails. Use it while you are still wiring handlers in Build and keep the patterns as you move into Operate. The skill emphasizes shipping observability in the application layer and forwarding events to external collectors without sacrificing Worker performance. It fits indie SaaS and API products that need production debugging discipline without a full platform team.

  • Structured JSON logging with correlation IDs for ephemeral Worker executions
  • Request-scoped distributed tracing with spans, timing, and metadata
  • Error boundaries and explicit capture with stack traces and request context
  • Monitoring pillar: error-rate tracking, latency percentiles, and alert thresholds
  • Designed for edge constraints: no log files, no injected APM—application-layer instrumentation only

Observability by the numbers

  • 54 all-time installs (skills.sh)
  • +3 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #705 of 1,039 Cloud & Infrastructure skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/itallstartedwithaidea/agent-skills --skill observability

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs54
repo stars31
Security audit3 / 3 scanners passed
Last updatedApril 12, 2026
Repositoryitallstartedwithaidea/agent-skills

What it does

Instrument Cloudflare Workers and edge apps with structured logs, traces, and error alerts so you can debug production without traditional APM agents.

Files

SKILL.mdMarkdownGitHub ↗

Observability

Part of Agent Skills™ by googleadsagent.ai™

Description

Observability implements structured logging, distributed tracing, and error monitoring for Cloudflare Workers and edge applications. The agent instruments code with contextual log entries, trace spans, error boundaries, and alerting rules that provide full visibility into production behavior without sacrificing performance.

Workers present unique observability challenges. There are no persistent processes to attach profilers to, no filesystem for log files, and no APM agent to inject. Observability must be built into the application layer through structured log events shipped to external collectors, request-scoped trace contexts, and explicit error capture with stack traces and request metadata.

This skill covers three pillars: Logging (structured JSON events with correlation IDs), Tracing (request-scoped spans with timing and metadata), and Monitoring (error rate tracking, latency percentiles, and alerting thresholds). Together, they answer the three questions of production debugging: what happened, how long did it take, and how often does it fail.

Use When

  • Adding logging to Workers or edge applications
  • Debugging production issues with distributed request tracing
  • Setting up error monitoring and alerting
  • Implementing health check endpoints
  • Measuring and reporting latency percentiles
  • Building dashboards for operational visibility

How It Works

graph TD
    A[Incoming Request] --> B[Generate Trace ID]
    B --> C[Start Root Span]
    C --> D[Execute Handler]
    D --> E[Child Spans for Subrequests]
    E --> F{Error?}
    F -->|Yes| G[Capture Error + Context]
    F -->|No| H[Record Success Metrics]
    G --> I[Structured Log: ERROR]
    H --> J[Structured Log: INFO]
    I --> K[Ship to Collector via waitUntil]
    J --> K
    K --> L[External: Datadog / Grafana / Sentry]
    C --> M[End Root Span + Record Latency]
    M --> K

Every request receives a trace ID that propagates through all subrequests and log entries. Spans measure duration of individual operations. Logs and spans are batched and shipped asynchronously via waitUntil() to avoid adding latency to the response.

Implementation

interface LogEntry {
  timestamp: string;
  level: "debug" | "info" | "warn" | "error";
  traceId: string;
  spanId: string;
  message: string;
  data?: Record<string, unknown>;
  error?: { name: string; message: string; stack?: string };
  duration_ms?: number;
}

class RequestTracer {
  private traceId: string;
  private spans: LogEntry[] = [];
  private startTime: number;

  constructor(request: Request) {
    this.traceId = request.headers.get("x-trace-id") ?? crypto.randomUUID();
    this.startTime = performance.now();
  }

  span<T>(name: string, fn: () => Promise<T>): Promise<T> {
    const spanId = crypto.randomUUID().slice(0, 8);
    const start = performance.now();
    return fn().then(
      result => {
        this.log("info", name, { duration_ms: performance.now() - start }, spanId);
        return result;
      },
      error => {
        this.log("error", name, {
          duration_ms: performance.now() - start,
          error: { name: error.name, message: error.message, stack: error.stack },
        }, spanId);
        throw error;
      }
    );
  }

  log(level: LogEntry["level"], message: string, data?: Record<string, unknown>, spanId?: string): void {
    this.spans.push({
      timestamp: new Date().toISOString(),
      level,
      traceId: this.traceId,
      spanId: spanId ?? "root",
      message,
      ...data,
    });
  }

  async flush(env: { LOG_COLLECTOR: Fetcher }): Promise<void> {
    const rootDuration = performance.now() - this.startTime;
    this.log("info", "request_complete", { duration_ms: rootDuration });

    await env.LOG_COLLECTOR.fetch("https://collector/ingest", {
      method: "POST",
      body: JSON.stringify(this.spans),
      headers: { "Content-Type": "application/json" },
    });
  }
}

export default {
  async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
    const tracer = new RequestTracer(request);
    try {
      const data = await tracer.span("fetch_data", () => fetchData(env));
      const html = await tracer.span("render", () => render(data));
      return new Response(html, { status: 200 });
    } catch (error) {
      tracer.log("error", "unhandled_error", {
        error: { name: (error as Error).name, message: (error as Error).message },
        url: request.url,
        method: request.method,
      });
      return new Response("Internal Error", { status: 500 });
    } finally {
      ctx.waitUntil(tracer.flush(env));
    }
  },
} satisfies ExportedHandler<Env>;

Best Practices

  • Ship logs asynchronously via waitUntil() to avoid adding latency to responses
  • Include trace IDs in all error responses so users can report them for debugging
  • Use structured JSON logging—never unstructured console.log in production
  • Set alerting thresholds on error rate (>1%) and p99 latency (>500ms)
  • Sample debug-level logs in production (1-10%) to control volume and cost
  • Propagate trace IDs across service boundaries via the x-trace-id header

Platform Compatibility

PlatformSupportNotes
CursorFullInstrumentation code generation
VS CodeFullLog viewer integration
WindsurfFullObservability patterns
Claude CodeFullWorker instrumentation
ClineFullLogging + tracing setup
aiderPartialCode-level instrumentation

Related Skills

  • Cloudflare Workers
  • CI/CD Pipelines
  • Service Discovery
  • Agent Security Scanning

Keywords

observability structured-logging distributed-tracing error-monitoring cloudflare-workers alerting latency trace-id

---

© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License

Related skills

FAQ

Is Observability safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Cloud & Infrastructuremonitoringdeployinfra

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.