Skip to content

Observability: structured logging, Analytics Engine, and OpenTelemetry hooks #69

Description

@PAMulligan

Summary

Replace ad-hoc console.log calls in the worker with structured logs, ship metrics to Cloudflare Analytics Engine, and expose OpenTelemetry hooks for users who want to forward telemetry to their own observability stack.

Motivation

The analytics dashboard answers product questions; observability answers operational questions. Without it, debugging production issues (a flaky tool call, a slow Anthropic response) is guesswork.

Acceptance Criteria

  • Worker logs are JSON with consistent fields: level, event, tenant, conversation_id, latency_ms, model, plus an error chain for failures
  • Counters and histograms pushed to Cloudflare Analytics Engine: chat.turn.latency, chat.tool.calls, chat.rate_limit.hits, chat.errors
  • OpenTelemetry tracer hook (createTracer()) lets users forward spans to their own collector
  • PII-safe by default: message bodies never logged unless LOG_MESSAGES=true (documented as off in prod)
  • Runbook in docs/operations.md covering common alerts and remediation steps

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendCloudflare Workers API and AI integrationenhancementNew feature or request

    Type

    No type

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions