Skip to content

Add optional App Health endpoint telemetry to the Worker API #57

Description

@sarthakagrawal927

Why

Reader is listed in the App Health 55-product rollout and its live rollout row has a browser CTA receipt, while API endpoint coverage remains unknown. Its Hono Cloudflare Worker exposes account, article, AI, PDF, RSS, and share APIs. A bounded opt-in endpoint integration would let the owner see aggregate route health without collecting reading content or account data.

What

Add optional App Health endpoint summaries to the /api/* Hono Worker pipeline using the official @saas-maker/app-health Hono adapter. The integration is disabled when the APP_HEALTH_INGEST_KEY binding is absent or blank. Record only method, Hono route template, status, duration, declared response byte count when available, and SDK timestamp. No release tag is supplied. Keep user-visible responses and handler errors unchanged.

Out of scope: adding or provisioning credentials, changing production bindings, deploying, browser/native telemetry changes, explicit App Health logs, identity/account fields, query strings, concrete path values, request/response bodies, headers, or a database migration.

Design

Install the official SDK from its immutable public node-v0.4.0 release tarball, as documented by App Health while npm publishing is unavailable. Mount the Hono middleware only on the existing API app. Resolve the client lazily from the optional Worker environment binding; configure runtime: 'worker', disableTimer: true, and ExecutionContext.waitUntil delivery. Reuse a module-scoped client for a stable key/environment tuple so the SDK can batch bursts; the binding values are never logged or included in telemetry. Hono's matched route template is used and tests confirm concrete paths, query values, headers, and bodies are excluded. No Wrangler/production configuration change is part of this work.

Specs

Requirement: Optional endpoint summaries

The Worker SHALL leave request behavior unchanged when App Health is unconfigured.

Scenario: Missing key

  • WHEN a request reaches an API route and the optional ingest-key binding is missing or blank
  • THEN the request receives its ordinary response and no telemetry is sent.

Requirement: Privacy-bounded route capture

The integration SHALL send only normalized method, matched Hono route template, status, duration, optional declared response byte count, SDK timestamp, and runtime/environment metadata.

Scenario: Dynamic article route

  • WHEN two article requests use different article identifiers and query values on the same matched route
  • THEN telemetry contains the same route template and contains neither identifier nor query value.

Scenario: Sensitive request data

  • WHEN a request carries authorization/cookie headers and a body
  • THEN no header, cookie, identity, query, parameter value, or body data is read or sent.

Requirement: Fail-open bounded delivery

The SDK SHALL use Worker waitUntil for asynchronous bounded delivery and SHALL NOT change successful, error, or not-found responses.

Scenario: Collector failure

  • WHEN App Health ingestion fails
  • THEN the product response and error handling remain unchanged.

Tasks

  • 1. Add the official SDK dependency and optional Worker binding/client resolver without editing secrets or production configuration.
  • 2. Mount endpoint middleware on API routes and add focused tests for disabled mode, route normalization/privacy, and response preservation.
  • 3. Run the smallest relevant Reader tests and checks, inspect the final diff, and prepare PR Add optional App Health endpoint telemetry #58 linked to this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions