Skip to content

chore: add tests for bot and blocked events dropped in processor - #6079

Merged
itsmihir merged 21 commits into
masterfrom
feature/pipe-2199-add-tests-for-bot-and-blocked-events-dropped-in-processor
Jul 18, 2025
Merged

itsmihir merged 21 commits into
masterfrom
feature/pipe-2199-add-tests-for-bot-and-blocked-events-dropped-in-processor

Conversation

@itsmihir

@itsmihir itsmihir commented Jul 3, 2025 •

Copy link
Copy Markdown
Contributor

Description

This PR adds integration tests to verify the processor correctly drops events based on bot detection and event blocking configurations. The tests ensure that events are properly filtered before reaching the router, preventing unwanted events from being processed downstream.

Linear Ticket

< PIPE-2199 >

Security

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

@itsmihir
itsmihir requested review from cisse21, fracasula and mihir20 July 3, 2025 13:29
@codecov

codecov Bot commented Jul 4, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.59%. Comparing base (40c1930) to head (d35dc71).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6079   +/-   ##
=======================================
  Coverage   76.59%   76.59%           
=======================================
  Files         522      522           
  Lines       69992    69992           
=======================================
+ Hits        53608    53612    +4     
- Misses      13473    13476    +3     
+ Partials     2911     2904    -7     

☔ View full report in Codecov by Sentry.
📢 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.

scenario.requireJobsCount(t, "rt", "aborted", 0)
scenario.requireJobsCount(t, "rt", "failed", 0)

scenario.requireTotalJobsCount(t, "rt", 0)

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.

for completeness we should also validate reporting metrics

@itsmihir
itsmihir changed the base branch from master to feature/rud-2407-emit-event-dropped-metrics-from-processor July 8, 2025 11:00
@itsmihir
itsmihir requested a review from mihir20 July 8, 2025 14:30
Comment on lines +47 to +49
scenario.requireReportsFromBotManagement(t, botManagementReportExpectations{eventType: "track", eventName: "TestEvent", botDroppedCount: 1})
scenario.requireReportsFromBotManagement(t, botManagementReportExpectations{eventType: "identify", eventName: "", botDroppedCount: 1})
scenario.requireReportsFromBotManagement(t, botManagementReportExpectations{eventType: "screen", eventName: "", botDroppedCount: 1})

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.

One thing I see with these tests is that, it could be possible that reports could be flushed to Reporting Service before these validations

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.

Need not fix it as part of this pr, but there is one more issue with these metrics. These reporting metrics are sent to the production reporting instance. I think we should fix it.

}

func (s *eventDropScenario) run(t *testing.T, verification func(t *testing.T, scenario *eventDropScenario)) {
config.Reset()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is the config.Reset() really needed? 🤔
Aren't we injecting the config properly in the processor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we don't need it, removing it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@itsmihir you're still using a global variable (i.e. config) though. Do you think you can get rid of it (if not too complex)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fracasula made changes to use t.Setenv instead of using global config.

itsmihir and others added 2 commits July 17, 2025 13:37
…sor' into feature/pipe-2199-add-tests-for-bot-and-blocked-events-dropped-in-processor
@itsmihir
itsmihir requested a review from fracasula July 17, 2025 08:08
itsmihir added a commit that referenced this pull request Jul 17, 2025
…#6087)

# Description

This PR enhances the event blocking feature by adding comprehensive
reporting metrics and optimizes the metrics collection process in the
processor.

## Changes 
1. Event Blocking Metrics Implementation
- Added reporting metrics for blocked events: Events that are dropped
due to event blocking now emit proper reporting metrics with status
`jobsdb.Filtered.State` and stage `reportingtypes.EVENT_BLOCKING`

2. Metrics Collection Optimization
- Reused `connectionDetailsMap`: Instead of creating separate connection
detail maps for each metric type, now reuses a single
`connectionDetailsMap` across all reporting metrics in `preprocessStage`

- Reduced memory allocation: This optimization reduces memory overhead
by eliminating duplicate connection metadata storage


## Technical Details
- Event blocking metrics are emitted when
`event.eventParams.IsEventBlocked` is true
- The blocked events are marked with `reportingtypes.FilterEventCode`
status code
- Metrics are collected using the existing `updateMetricMaps` function
with proper parameters
- All reporting metrics in `preprocessStage` now share the same
`connectionDetailsMap` instance:
  - statusDetailsMap (Gateway metrics)
  - enricherStatusDetailsMap (Enricher metrics)
  - botManagementStatusDetailsMap (Bot management metrics)
  - eventBlockingStatusDetailsMap (Event blocking metrics)
  - destFilterStatusDetailMap (Destination filter metrics)
 
## Related PR
- #6079 - Comprehensive integration tests for bot detection and event
blocking functionality are being added in a separate PR


## Linear Ticket

<
[RUD-2407](https://linear.app/rudderstack/issue/RUD-2407/emit-event-dropped-metrics-from-processor)
>

## Security

- [ ] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
Base automatically changed from feature/rud-2407-emit-event-dropped-metrics-from-processor to master July 17, 2025 11:28
@itsmihir
itsmihir enabled auto-merge (squash) July 17, 2025 15:49
@itsmihir
itsmihir merged commit d85d53d into master Jul 18, 2025
@itsmihir
itsmihir deleted the feature/pipe-2199-add-tests-for-bot-and-blocked-events-dropped-in-processor branch July 18, 2025 06:27
This was referenced Jul 21, 2025
itsmihir pushed a commit that referenced this pull request Jul 21, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.55.0-rc.1](v1.53.0...v1.55.0-rc.1)
(2025-07-21)


### Features

* add support for snowpipe destination in rudder-cli
([#6055](#6055))
([417b2f5](417b2f5))
* implement configurable event blocking
([#6018](#6018))
([0901e5f](0901e5f))
* implement leaky uploader for invalid payloads
([#6072](#6072))
([d17efc1](d17efc1))
* propagate snowpipe iceberg config to snowpipe service
([#6013](#6013))
([0901e5f](0901e5f))
* **router:** support TRANSFORMER_PROXY_URL for dedicated transformer
proxy ([#6110](#6110))
([eff32e6](eff32e6))
* staging files schema snapshot cached repository with different
strategies
([#6099](#6099))
([943d112](943d112))
* **warehouse:** add schema snapshots table and link to staging files
(WAR-866)
([#6095](#6095))
([d6a5ea7](d6a5ea7))


### Bug Fixes

* avoid cleanup object storage for datalakes
([#6133](#6133))
([3143f04](3143f04))
* bigquery load errors population
([#6065](#6065))
([75085f2](75085f2))
* custom type in payload during enrichment
([#6064](#6064))
([75085f2](75085f2))
* disable column index for parquet writer
([#6088](#6088))
([29f93ce](29f93ce))
* disable column index for parquet writer
([#6088](#6088))
([0b5b169](0b5b169))
* disable column index for parquet writer
([#6088](#6088))
([a8f5adb](a8f5adb))
* disable column index for parquet writer
([#6088](#6088))
([71eee56](71eee56))
* duplicate load files for datalakes
([#6037](#6037))
([c19d8d9](c19d8d9))
* ensure hasDynamicConfig field always present in DestinationT JSON
([#6057](#6057))
([7a1c1d6](7a1c1d6))
* personalise aws v2 implementation fails with unmarshal error
([#6050](#6050))
([7a1c1d6](7a1c1d6))
* remove region from provider config for backups
([#6109](#6109))
([29f93ce](29f93ce))
* remove region from provider config for backups
([#6109](#6109))
([0b5b169](0b5b169))
* set payloadStage based on reportJobsdbPayload flag
([#6107](#6107))
([f642bed](f642bed))
* statsExcludedTags causes server to shutdown immediately
([#6060](#6060))
([7a1c1d6](7a1c1d6))
* update validation and conversion of timestamp to bingads offline
conversion supported format
([#6082](#6082))
([29f93ce](29f93ce))
* update validation and conversion of timestamp to bingads offline
conversion supported format
([#6082](#6082))
([0b5b169](0b5b169))
* update validation and conversion of timestamp to bingads offline
conversion supported format
([#6082](#6082))
([a8f5adb](a8f5adb))
* update validation and conversion of timestamp to bingads offline
conversion supported format
([#6082](#6082))
([abdb9fc](abdb9fc))


### Miscellaneous

* add cursor rules for warehouse
([#6086](#6086))
([b8b46fa](b8b46fa))
* add logging for HasDynamicConfig flag in destination config
([#6054](#6054))
([7a1c1d6](7a1c1d6))
* add logging to trace double-encoded HLL value issue
([#6044](#6044))
([4bddb5d](4bddb5d))
* add server instance id in warehouse staging file metadata
([#6076](#6076))
([6fff7e1](6fff7e1))
* add tests for bot and blocked events dropped in processor
([#6079](#6079))
([d85d53d](d85d53d))
* change refresh time log to info
([#6073](#6073))
([b29b472](b29b472))
* clean up savePayloadOnError config
([#6104](#6104))
([7264c0b](7264c0b))
* drop bot events in processor after capturing metrics
([#6052](#6052))
([5e2efc5](5e2efc5))
* emit reporting metrics for event dropped due to event blocking
([#6087](#6087))
([40c1930](40c1930))
* enhance rsources stats collector with component tagging and error
handling
([#6124](#6124))
([29f93ce](29f93ce))
* generate temp creds in v2 for databricks
([#6136](#6136))
([0d09c37](0d09c37))
* inject stats in source transformer
([#6047](#6047))
([4998beb](4998beb))
* keydb deduplication mirroring
([#6058](#6058))
([7a1c1d6](7a1c1d6))
* oauth platform error logs
([#6053](#6053))
([7a1c1d6](7a1c1d6))
* postgres docker load test
([#6061](#6061))
([a7b4ceb](a7b4ceb))
* reset timer to optimise router batching
([#6114](#6114))
([f9db3c5](f9db3c5))
* **router:** rename TRANSFORMER_PROXY_URL to DELIVERY_TRANSFORMER_URL
for transformer proxy
([#6120](#6120))
([81dbec0](81dbec0))
* sync release v1.54.0 to main branch
([#6078](#6078))
([9fdb24e](9fdb24e))
* update config key for dedup window in KeyDB
([#6135](#6135))
([867dc8b](867dc8b))
* update golang.org/x/sync to v0.16.0
([#6111](#6111))
([29f93ce](29f93ce))
* update golang.org/x/sync to v0.16.0
([#6111](#6111))
([0b5b169](0b5b169))
* upgrade go kit
([#6103](#6103))
([29f93ce](29f93ce))
* upgrade go kit
([#6103](#6103))
([0b5b169](0b5b169))
* upgrade go kit
([#6103](#6103))
([a8f5adb](a8f5adb))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
itsmihir pushed a commit that referenced this pull request Jul 22, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.55.0](v1.53.0...v1.55.0)
(2025-07-22)


### Features

* add support for snowpipe destination in rudder-cli
([#6055](#6055))
([417b2f5](417b2f5))
* handling schema consolidation
([#6101](#6101))
([59437e6](59437e6))
* implement configurable event blocking
([#6018](#6018))
([0901e5f](0901e5f))
* implement leaky uploader for invalid payloads
([#6072](#6072))
([d17efc1](d17efc1))
* propagate snowpipe iceberg config to snowpipe service
([#6013](#6013))
([0901e5f](0901e5f))
* **router:** support TRANSFORMER_PROXY_URL for dedicated transformer
proxy ([#6110](#6110))
([eff32e6](eff32e6))
* segmented storage
([#6117](#6117))
([45269f4](45269f4))
* staging files schema snapshot cached repository with different
strategies
([#6099](#6099))
([943d112](943d112))
* start populating snapshot id and schema patch
([#6100](#6100))
([3873cb5](3873cb5))
* **warehouse:** add schema snapshots table and link to staging files
(WAR-866)
([#6095](#6095))
([d6a5ea7](d6a5ea7))


### Bug Fixes

* avoid cleanup object storage for datalakes
([#6133](#6133))
([3143f04](3143f04))
* bigquery load errors population
([#6065](#6065))
([75085f2](75085f2))
* custom type in payload during enrichment
([#6064](#6064))
([75085f2](75085f2))
* disable column index for parquet writer
([#6088](#6088))
([29f93ce](29f93ce))
* disable column index for parquet writer
([#6088](#6088))
([0b5b169](0b5b169))
* disable column index for parquet writer
([#6088](#6088))
([a8f5adb](a8f5adb))
* disable column index for parquet writer
([#6088](#6088))
([71eee56](71eee56))
* duplicate load files for datalakes
([#6037](#6037))
([c19d8d9](c19d8d9))
* empty bucket with use rudder storage
([#6145](#6145))
([e2b8563](e2b8563))
* ensure hasDynamicConfig field always present in DestinationT JSON
([#6057](#6057))
([7a1c1d6](7a1c1d6))
* personalise aws v2 implementation fails with unmarshal error
([#6050](#6050))
([7a1c1d6](7a1c1d6))
* remove region from provider config for backups
([#6109](#6109))
([29f93ce](29f93ce))
* remove region from provider config for backups
([#6109](#6109))
([0b5b169](0b5b169))
* set payloadStage based on reportJobsdbPayload flag
([#6107](#6107))
([f642bed](f642bed))
* statsExcludedTags causes server to shutdown immediately
([#6060](#6060))
([7a1c1d6](7a1c1d6))
* update validation and conversion of timestamp to bingads offline
conversion supported format
([#6082](#6082))
([29f93ce](29f93ce))
* update validation and conversion of timestamp to bingads offline
conversion supported format
([#6082](#6082))
([0b5b169](0b5b169))
* update validation and conversion of timestamp to bingads offline
conversion supported format
([#6082](#6082))
([a8f5adb](a8f5adb))
* update validation and conversion of timestamp to bingads offline
conversion supported format
([#6082](#6082))
([abdb9fc](abdb9fc))


### Miscellaneous

* add cursor rules for warehouse
([#6086](#6086))
([b8b46fa](b8b46fa))
* add logging for HasDynamicConfig flag in destination config
([#6054](#6054))
([7a1c1d6](7a1c1d6))
* add logging to trace double-encoded HLL value issue
([#6044](#6044))
([4bddb5d](4bddb5d))
* add server instance id in warehouse staging file metadata
([#6076](#6076))
([6fff7e1](6fff7e1))
* add tests for bot and blocked events dropped in processor
([#6079](#6079))
([d85d53d](d85d53d))
* bump the go-deps group across 1 directory with 19 updates
([#6140](#6140))
([dfb37d4](dfb37d4))
* change refresh time log to info
([#6073](#6073))
([b29b472](b29b472))
* change release to 1.55.0
([#6152](#6152))
([4ab9c3b](4ab9c3b))
* clean up savePayloadOnError config
([#6104](#6104))
([7264c0b](7264c0b))
* drop bot events in processor after capturing metrics
([#6052](#6052))
([5e2efc5](5e2efc5))
* emit reporting metrics for event dropped due to event blocking
([#6087](#6087))
([40c1930](40c1930))
* enhance rsources stats collector with component tagging and error
handling
([#6124](#6124))
([29f93ce](29f93ce))
* generate temp creds in v2 for databricks
([#6136](#6136))
([0d09c37](0d09c37))
* inject stats in source transformer
([#6047](#6047))
([4998beb](4998beb))
* keydb deduplication mirroring
([#6058](#6058))
([7a1c1d6](7a1c1d6))
* oauth platform error logs
([#6053](#6053))
([7a1c1d6](7a1c1d6))
* postgres docker load test
([#6061](#6061))
([a7b4ceb](a7b4ceb))
* reset timer to optimise router batching
([#6114](#6114))
([f9db3c5](f9db3c5))
* **router:** rename TRANSFORMER_PROXY_URL to DELIVERY_TRANSFORMER_URL
for transformer proxy
([#6120](#6120))
([81dbec0](81dbec0))
* sync release v1.54.0 to main branch
([#6078](#6078))
([9fdb24e](9fdb24e))
* update config key for dedup window in KeyDB
([#6135](#6135))
([867dc8b](867dc8b))
* update golang.org/x/sync to v0.16.0
([#6111](#6111))
([29f93ce](29f93ce))
* update golang.org/x/sync to v0.16.0
([#6111](#6111))
([0b5b169](0b5b169))
* upgrade go kit
([#6103](#6103))
([29f93ce](29f93ce))
* upgrade go kit
([#6103](#6103))
([0b5b169](0b5b169))
* upgrade go kit
([#6103](#6103))
([a8f5adb](a8f5adb))
* use errgroup.Group instead of kitsync.ErrGroup
([#6146](#6146))
([90bf121](90bf121))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

4 participants