chore: minimize PostHog tracking to cut event volume - #3839
Closed
laststylebender14 wants to merge 7 commits into
Closed
chore: minimize PostHog tracking to cut event volume#3839laststylebender14 wants to merge 7 commits into
laststylebender14 wants to merge 7 commits into
Conversation
- Ship only error-level logs to PostHog (was info-level) - Truncate trace payloads to 1024 bytes before dispatch
…king - Remove EventKind::Prompt and EventKind::ToolCall (and ToolCallPayload) - Stop attaching full Conversation objects to tracked events - Keep Start, Error, Login, and (truncated) Trace events
Traces are now error-level only, so send them in full.
laststylebender14
force-pushed
the
chore/minimal-posthog-tracking
branch
from
August 10, 2026 05:54
b73aa4e to
f1d08f9
Compare
- Remove EventKind::Trace and the log-shipping PostHogWriter - Logs always go to local rolling forge.log (info when tracking, debug otherwise) - Add PosthogErrorLayer: error-level tracing events from forge_ modules are dispatched to PostHog as Error events (single pipeline, no double-send) - Remove manual tracker::error()/error_string() helpers; keep error_blocking for the panic hook - Lower event rate limit from 1000/min to 60/min
Newer clippy nightlies flag #[async_trait]-generated methods (which return an already-must-use Pin<Box<dyn Future>> with an implicit #[must_use]) as double_must_use, breaking the Lint Fix CI job on all branches. Allow the lint workspace-wide via [workspace.lints] and opt every crate in.
laststylebender14
marked this pull request as ready for review
August 10, 2026 06:18
- Add Tracker::with_collectors test constructor for collector injection - Add capture_events fixture that runs a closure under the layer and returns all dispatched (name, value) pairs - Verify: error events dispatch with exact file:line/message/field rendering, non-error levels and non-forge targets are ignored, and multiple errors arrive as distinct ordered events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
We were getting huge PostHog bills due to over-tracking (billed per event). This PR minimizes what we send:
What PostHog receives now
start— once per sessionlogin— once per sessionerror— error-level events only, capped at 60/min (was 1000/min)Changes
EventKind::Traceand thePostHogWriterlog-shipping pipeline — previously every info-level log line was billed as a separatetraceevent, and errors were double-sent (once aserror, again astrace).PosthogErrorLayer— atracingLayer that forwards error-level events fromforge_*modules to PostHog aserrorevents. This is now the single error pipeline: anytracing::error!anywhere in the workspace is tracked once, with no manual call-site wiring.EventKind::Prompt/EventKind::ToolCall— no longer send user prompt text or per-tool-call events.Conversationpayloads from tracked events.forge.log(forge=infowhen tracking is enabled,forge=debugotherwise) — previously enabling tracking meant no local log file at all.tracker::error()/error_string()helpers; kepterror_blocking()for the panic hook (sync dispatch is safer during a panic).Testing
cargo check --workspace— clean, no warningscargo test -p forge_tracker— all tests pass