Skip to content

feat: gateway_ingested counter for all events entering preprocess - #7328

Merged
mihir20 merged 13 commits into
pipeline-inspector/03-user-suppression-counterfrom
pipeline-inspector/04-gateway-ingested-counter
Sep 7, 2026
Merged

mihir20 merged 13 commits into
pipeline-inspector/03-user-suppression-counterfrom
pipeline-inspector/04-gateway-ingested-counter

Conversation

@mihir20

@mihir20 mihir20 commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a new gateway_ingested reporting PU that counts every event entering the processor's preprocess stage — including events that are subsequently dropped (bot, blocked, suppressed, dedup, filtered). This gives the pipeline inspector a stable "everything that came in" baseline to reconcile all downstream drop/filter rows against: gateway_ingested = delivered + all drop rows + multiplexed.

What changed

  • New GATEWAY_INGESTED PU (utils/types/reporting_types.go): reported as a standalone side PU (inPU: "", not part of the terminal/initial PU chain), so the existing gateway billing row and PU chains are untouched.
  • Counter emission in preprocess (processor/processor.go): in preprocessStage, before any drop decision is made, every event is recorded into a new gatewayIngestedStatusDetailsMap as a succeeded row with StatusCode: 200. The shared reporting event's status code is reset to 0 right after, so the gateway billing row keeps its StatusCode: 0 as before. The map is threaded through preTransformationMessage → srcHydrationMessage → pretransformStage, where rows are flushed into reportMetrics alongside the other drop-metric maps (with the usual AssertKeysSubset guard).
  • Feature flag: emission is gated behind reloadable Reporting.gatewayIngestedMetrics.enabled (default false) and requires reporting to be enabled. With the flag off, report metrics are identical to before.

Semantics

  • One gateway_ingested row aggregates events with the same source/name/type; rows split by event type.
  • Dropped events are still counted — that's the point of the baseline.
  • A bot event that is flagged but not dropped counts exactly once in both gateway_ingested and gateway.

Tests

  • processor/processor_test.go — new TestGatewayIngestedReporting covering flag on/off, reporting disabled, mixed batches with drops, all-dropped batches, aggregation/splitting by event type, billing-row StatusCode unaffected, and bot-flagged-but-not-dropped events.
  • integration_test/reporting_dropped_events — consent-filter scenario verifying per-destination visibility at the destination-filter boundary (destination_enter rows per candidate destination, per-destination filtered_consent rows, filtered_no_destination for zero-candidate events), with Processor.earlyDestinationFilter both on and off.

Remaining processor.go hunks are formatting-only (argument wrapping from make fmt).

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@mihir20

mihir20 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Stack (merge bottom-up)

@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.28%. Comparing base (891feb3) to head (9fc8305).

Additional details and impacted files
@@                                Coverage Diff                                 @@
##           pipeline-inspector/03-user-suppression-counter    #7328      +/-   ##
==================================================================================
+ Coverage                                           80.23%   80.28%   +0.05%     
==================================================================================
  Files                                                 611      611              
  Lines                                               68467    68492      +25     
==================================================================================
+ Hits                                                54934    54990      +56     
+ Misses                                              10302    10266      -36     
- Partials                                             3231     3236       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

… boundary

Add classifyDestinations as the single classification site at fan-out,
narrowing the candidate set to the RETL-stamped destination before
classification, and emit per-candidate destination_enter succeeded/200
rows (Reporting.destinationEnterMetrics.enabled) plus per-destination
filtered_integration/298 and filtered_consent/297 destination_filter
rows (Reporting.perDestinationFilterMetrics.enabled), with a
filtered_no_destination/298 carve-out for zero-candidate events.

Processor.earlyDestinationFilter (default true) gates the reorder: when
false the preprocess destination-filter guard is skipped so all events
reach source hydration and tracking-plan validation, fan-out becomes the
drop point, and the inPU chain labels are rewired to the new stage order
(source_hydration=gateway, tracking_plan_validator=srchyd|gateway,
user_transformer=destination_filter). The flag is snapshotted once per
batch and threaded through the stage messages so one in-flight batch
never observes mixed values. All flags are reloadable and default to
byte-identical-to-today behavior.

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
…ctions and update related logic

🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
… destination classification

🔒 Scanned for secrets using gitleaks 8.28.0
- procRebuildStage: describe soft-deletion/disabled as the real config-drift
  case and the missing-destination drop as a defensive fallback (review
  r3878718615)
- classifyDestinations: replace invented 'sibling destinations' term with an
  explanation in terms of RETL per-connection copies (review r3878840812),
  and retire the term from test names

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
…es 298

Per review (r3829990734): the status string, not the status code, is the
discriminator within the filtered_* family — filtered_integration,
filtered_no_destination and the filtered rows of dedup already share
FilterEventCode = 298, so a dedicated 297 for filtered_consent added no
information (and collided with StatusMirrorFiltered = 297 in
processor/internal/transformer).

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
…y jobs

Suppressed events currently vanish at the gateway with only a prometheus
stat. Behind the new reloadable flag Gateway.storeUserSuppressedEvents
(default false), the gateway now stores a dummy job instead — payload
stripped to messageId/type/event/receivedAt so no user data survives
suppression — marked is_user_suppressed in the job parameters and
excluded from live-event recording, on both the public and internal
batch paths (a fully-suppressed public request stores N dummy jobs and
returns 200 instead of short-circuiting via errRequestSuppressed).

The processor recognises the parameter at the top of the preprocess
loop — before bot management, event blocking, dedup and the GATEWAY
billing metric — emits one filtered/298 row under the new standalone
USER_SUPPRESSION PU (reportedBy is the discriminator, like dedup), and
unconditionally drops the event, following the bot-blocking pattern.
Billing, dedup keys, event schemas and archival are untouched.

The processor side is complete with the gateway flag off, so the flag
may only be enabled once all processor pods run this version.

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
The public path (getJobDataFromRequest) always drops suppressed events
again, regardless of Gateway.storeUserSuppressedEvents — reverting its
dummy-job block and the per-job parameters override, so a
fully-suppressed public request short-circuits via errRequestSuppressed
exactly as before this branch. The flag now only controls the internal
batch path, where suppressed events become stripped dummy jobs reported
and dropped at the processor.

Public-path Ginkgo specs replaced with a guard that the flag never
leaks back into that path; the integration subtest now drives
/internal/v1/batch for the flag-on flow and pins that /v1/batch stores
nothing even with the flag on.

🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20
mihir20 force-pushed the pipeline-inspector/03-user-suppression-counter branch from 544f5e0 to 262bba3 Compare September 1, 2026 10:35
@mihir20
mihir20 force-pushed the pipeline-inspector/04-gateway-ingested-counter branch from 3675568 to 845292e Compare September 1, 2026 10:50
🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20
mihir20 force-pushed the pipeline-inspector/04-gateway-ingested-counter branch from 845292e to a9e1b47 Compare September 1, 2026 10:59
…process

Adds a GATEWAY_INGESTED side PU (inPU empty, initial=false) emitted at the
very top of the preprocess per-event loop, before the user-suppression, bot,
event-blocking and dedup checks and the GATEWAY billing metric, so every
iterated event is counted and the funnel's drop side-PUs subtract from it:
gateway_ingested - (user_suppression + event_blocking + dedup + dropped
bot_management) = gateway. Gated by the new reloadable flag
Reporting.gatewayIngestedMetrics.enabled (default false); with it off,
report output is unchanged. The GATEWAY billing rows stay byte-identical.

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20
mihir20 force-pushed the pipeline-inspector/04-gateway-ingested-counter branch from a9e1b47 to 24423e1 Compare September 1, 2026 11:38
…ession-counter' into pipeline-inspector/04-gateway-ingested-counter

# Conflicts:
#	processor/processor.go
#	processor/processor_test.go
#	processor/src_hydration_stage.go

🔒 Scanned for secrets using gitleaks 8.28.0
@mihir20 mihir20 changed the title feat(processor): gateway_ingested counter for all events entering preprocess feat: gateway_ingested counter for all events entering preprocess Sep 1, 2026
@mihir20
mihir20 requested review from atzoum and itsmihir September 1, 2026 13:37
@mihir20
mihir20 force-pushed the pipeline-inspector/03-user-suppression-counter branch from 891feb3 to 2ce9f18 Compare September 2, 2026 07:27
Comment thread processor/processor.go Resolved
Comment thread processor/processor.go
@@ -2452,6 +2480,14 @@ func (proc *Handle) pretransformStage(partition string, preTrans *preTransformat
})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit] Can we move this collection before the BOT_MANAGEMENT stage collection around line 2450? It would improve readability and follow the same semantic order.

USER_SUPPRESSION = "user_suppression"
DEDUP = "dedup"
GATEWAY = "gateway"
GATEWAY_INGESTED = "gateway_ingested"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In postgres each character counts

Suggested change
GATEWAY_INGESTED = "gateway_ingested"
GATEWAY_INGESTED = "gw_ingested"

eventBlockingStatusDetailsMap map[string]map[string]*reportingtypes.StatusDetail
userSuppressionStatusDetailsMap map[string]map[string]*reportingtypes.StatusDetail
dedupStatusDetailsMap map[string]map[string]*reportingtypes.StatusDetail
gatewayIngestedStatusDetailsMap map[string]map[string]*reportingtypes.StatusDetail

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yet-another status detail map...

Comment thread processor/processor.go
proc.config.userTransformationMirroringBlockedIDs = proc.conf.GetReloadableStringSliceVar(nil, "Processor.userTransformationMirroring.blockedTransformationIDs")
proc.config.storeSamplerEnabled = proc.conf.GetReloadableBoolVar(false, "Processor.storeSamplerEnabled")
proc.config.reportingDedupMetricsEnabled = proc.conf.GetReloadableBoolVar(false, "Reporting.dedupMetrics.enabled")
proc.config.reportingGatewayIngestedMetricsEnabled = proc.conf.GetReloadableBoolVar(false, "Reporting.gatewayIngestedMetrics.enabled")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
proc.config.reportingGatewayIngestedMetricsEnabled = proc.conf.GetReloadableBoolVar(false, "Reporting.gatewayIngestedMetrics.enabled")
proc.config.reportingGatewayIngestedMetricsEnabled = proc.conf.GetReloadableBoolVar(false, "Reporting.gatewayIngestedMetricsEnabled")

@mihir20
mihir20 merged commit 679ba61 into pipeline-inspector/03-user-suppression-counter Sep 7, 2026
113 of 116 checks passed
@mihir20
mihir20 deleted the pipeline-inspector/04-gateway-ingested-counter branch September 7, 2026 06:40
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.

3 participants