Skip to content

feat(cdp): label email queue waits that the team sending cap delayed - #126304

Merged
trunk-io[bot] merged 1 commit into
masterfrom
posthog/email-queue-wait-team-capped-label
Nov 2, 2026
Merged

trunk-io[bot] merged 1 commit into
masterfrom
posthog/email-queue-wait-team-capped-label

Conversation

@mayteio

@mayteio mayteio commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • On-call gets a slow transactional email warning when one project passes its sending cap, with nothing broken (PostHog/charts#18928).
  • The queue-to-SES histogram can't tell the cap's deliberate wait from a slow worker.

Changes

  • cdp_email_queue_to_send_ms gets a team_capped label, true when the team sending cap delayed the send.
  • A cap reschedule sets teamCapped in the job's queue metadata, which survives the reschedule.
  • The charts alert filters team_capped!="true", so deploy order does not matter.
  • No user-visible change.

How did you test this code?

Test rationale: One capped row in the queue-to-send test.each, and one assertion in the cap reschedule test. They fail if the flag stops reaching the label.

  • Not checked: a real cap delay through the Postgres queue.

Release status

  • No feature flag controls this change

Docs update

  • None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Claude Opus 5.5

Skills: /writing-tests, /writing-code-comments, /writing-pr-descriptions

More context for AI agents
  • Session: PostHog Desktop task; gh, jest, vmalert-tool
  • Decisions: A label, not dropping capped samples, so a dashboard can still show the cap wait.
  • Decisions: The SES throttle and workflow rate limit reschedules still drop queue metadata, so a capped send that then hits one of them reads as not capped.
  • Read closely: the queueMetadata write in the cap branch of email.service.ts.

Created with PostHog Desktop from a PostHog Desktop task

🤖 Generated with Claude Code

A send that the team sending cap reschedules now carries `teamCapped` in its queue metadata. The email queue persists that metadata across the reschedule, and `cdp_email_queue_to_send_ms` reports it as the `team_capped` label. The transactional email slow alert in PostHog/charts can then leave out a wait that the cap causes on purpose.

Generated-By: PostHog Desktop
Task-Id: eaee842b-1d54-46ae-8701-cd396156b16c
@mayteio mayteio self-assigned this Oct 30, 2026
@trunk-io

trunk-io Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

✅ Trunk lane — non-backend lane

This PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

@hosthog

hosthog Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

HostHog preview — posthog-desktop-web

The previews for this PR have been torn down and no longer serve.

@mayteio
mayteio marked this pull request as ready for review November 2, 2026 11:16
@parameterai

parameterai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Risk: No findings

This change adds a team_capped label to the email queue-wait histogram and stamps teamCapped into internal queue metadata when a team sending cap reschedules a send, so alerts can exclude deliberate cap waits. The label is a fixed boolean rendered as 'true'/'false', so it introduces no unbounded cardinality, injection, or data-exposure risk.

Sentinel reviewed 849cb20 · Review settings

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team November 2, 2026 11:17
@mayteio mayteio added the stamphog Request AI approval (no full review) label Nov 2, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

The queue-metadata change has owning-team and STRONG-familiarity assurance, with targeted tests added. No unresolved substantive review concerns or other refusal grounds were found.

  • Author wrote 100% of the modified lines and has 7 merged PRs in these paths (familiarity STRONG).
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 10L, 1F substantive, 34L/2F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1b-small (34L, 2F, single-area, feat)
stamphog 2.6.1 .stamphog/policy.yml @ 849cb20 · reviewed head 849cb20

@trunk-io
trunk-io Bot merged commit 55638a0 into master Nov 2, 2026
321 checks passed
@trunk-io
trunk-io Bot deleted the posthog/email-queue-wait-team-capped-label branch November 2, 2026 12:49
@deployment-status-posthog

deployment-status-posthog Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-11-02 13:17 UTC Run
prod-us ✅ Deployed 2026-11-02 13:43 UTC Run
prod-eu ✅ Deployed 2026-11-02 13:36 UTC Run

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

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant