Skip to content

feat(telemetry): adopt shared PostHog schema v2 (server events, features, flush)#96

Merged
jrosskopf merged 1 commit into
mainfrom
feat/telemetry-schema-v2
Jul 13, 2026
Merged

feat(telemetry): adopt shared PostHog schema v2 (server events, features, flush)#96
jrosskopf merged 1 commit into
mainfrom
feat/telemetry-schema-v2

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Upgrades flapi onto the shared DataZoo telemetry schema (telemetry_schema: 2). flapi is a long-running server, so install_kind="server" and one $session_id per uptime.

  • Upgrade the posthog-telemetry submodule to the v2.0.0 API (SetProduct, CaptureFeature, AssociateGroup, CaptureError, Flush).
  • Boot: SetProduct("flapi", …), install_kind="server", deployment group (optional account via FLAPI_LICENSE_ID), and server_started{endpoint_count, auth_kind} (counts/kinds only).
  • Per request/tool/auth: rest_endpoint_served{method, route_template, status_class, duration_ms, cache_hit} at the single REST choke point; mcp_tool_called{tool, status_class, duration_ms}; auth_enforced{auth_kind, outcome}; $exception with an enumerated error_class.
  • Privacy: the route template (never the filled path), and bounded enum/number props only — no URL/query/body/headers/SQL. Verified by a no-leak test that drives the real library transport and asserts the serialized batch is clean.
  • Lifecycle: Flush() on SIGINT/SIGTERM and clean exit (the library's at-exit handler discards by design). Single opt-out via --no-telemetry / FLAPI_NO_TELEMETRY / DATAZOO_DISABLE_TELEMETRY / telemetry.enabled: false; optional telemetry.sample_rate for high-QPS.
  • Docs: TELEMETRY.md listing exactly what is collected.

cache_hit reports whether the endpoint is cache-backed (flapi has no per-request hit/miss signal — documented in TELEMETRY.md).

Test plan

  • Debug build clean; flapi-lib + tests link against the upgraded lib.
  • Telemetry unit tests: 12 cases / 65 assertions pass, incl. the real-transport no-leak test (asserts route template present; no filled path / SQL / Authorization / password).
  • Smoke (first pass): server boots, requests flow the instrumented choke point, SIGTERM flushes + clean exit.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

…res, flush)

- Upgrade posthog-telemetry submodule to the v2.0.0 API (SetProduct,
  CaptureFeature, AssociateGroup, CaptureError, Flush)
- Emit against the shared DataZoo schema: product=flapi, install_kind="server",
  one $session_id per uptime, deployment group at boot (optional account group
  via FLAPI_LICENSE_ID)
- server_started{endpoint_count, auth_kind}; one rest_endpoint_served per
  request {method, route_template, status_class, duration_ms, cache_hit};
  mcp_tool_called{tool, status_class, duration_ms}; auth_enforced{auth_kind,
  outcome}; $exception with enumerated error_class
- Route TEMPLATE only (never the filled path); bounded enum/number props only —
  never URL/query/body/headers/SQL (verified by a real-transport no-leak test)
- Flush() on SIGINT/SIGTERM and clean exit; single opt-out via --no-telemetry /
  FLAPI_NO_TELEMETRY / DATAZOO_DISABLE_TELEMETRY / telemetry.enabled:false;
  optional telemetry.sample_rate for high-QPS deployments
- Add TELEMETRY.md documenting exactly what is collected
@jrosskopf jrosskopf merged commit 79f37b8 into main Jul 13, 2026
21 checks passed
@jrosskopf jrosskopf deleted the feat/telemetry-schema-v2 branch July 13, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant