Skip to content

feat: capture bot metrics post deduplication - #5956

Merged
itsmihir merged 13 commits into
masterfrom
feat.capture-bot-metric
Jun 12, 2025
Merged

itsmihir merged 13 commits into
masterfrom
feat.capture-bot-metric

Conversation

@itsmihir

@itsmihir itsmihir commented Jun 6, 2025 •

Copy link
Copy Markdown
Contributor

Description

This PR adds bot metrics reporting to the processor pipeline that occurs after event deduplication. Previously, bot events were only enriched with context but no metrics were captured for observability. Now, when IsBot=true, the system reports bot metrics with different statuses based on the new BotAction field: BotDetectedStatus for detected bots and BotFlaggedStatus when BotAction="flag".

Key Changes

1. BotAction Field Introduction

  • Added BotAction field to event parameters across the pipeline (gateway/handle.go, processor/types/types.go)
  • Supports two primary actions:
    • "flag": Bot events are enriched with bot context and reported as flagged
    • "disable": Bot events are detected but not enriched or reported
    • Empty/missing: Maintains backward compatibility for existing ingestion services

2. Enhanced Bot Enrichment Logic (internal/enricher/bot.go)

  • Modified bot enricher to respect the BotAction field
  • Only enriches events when BotAction is "flag" or empty (backward compatibility)
  • Skips enrichment when BotAction is "disable" or any other value
  • Added comprehensive test coverage for all BotAction scenarios

3. Added Bot Metrics Reporting (processor/processor.go)

  • Bot metrics are now captured post-deduplication to ensure accurate counts
  • Differentiated reporting based on BotAction:
    • BotDetectedStatus: When bot is detected but not flagged
    • BotFlaggedStatus: When bot is detected and flagged (BotAction = "flag")
  • Metrics are captured separately from regular event processing to avoid double-counting

Technical Benefits

  1. Accurate Metrics: Bot metrics are now captured after deduplication, preventing inflated bot counts
  2. Flexible Bot Handling: The BotAction field allows fine-grained control over bot processing
  3. Backward Compatibility: Existing systems continue to work without the BotAction field
  4. Better Observability: Separate metrics for detected vs. flagged bots provide clearer insights

Linear Ticket

Resolves OBS-846

Security

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

@codecov

codecov Bot commented Jun 6, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.93%. Comparing base (3e0dc6f) to head (630cc91).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5956      +/-   ##
==========================================
+ Coverage   76.84%   76.93%   +0.08%     
==========================================
  Files         495      495              
  Lines       68528    68569      +41     
==========================================
+ Hits        52663    52754      +91     
+ Misses      12991    12952      -39     
+ Partials     2874     2863      -11     

☔ 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.

@itsmihir
itsmihir marked this pull request as ready for review June 9, 2025 14:38
@itsmihir
itsmihir requested review from fracasula, ktgowtham, mihir20 and satishrudderstack and removed request for fracasula June 9, 2025 14:38
Comment thread processor/processor.go
connectionDetailsMap: connectionDetailsMap,
statusDetailsMap: statusDetailsMap,
enricherConnectionDetailsMap: enricherConnectionDetailsMap,
enricherStatusDetailsMap: enricherStatusDetailsMap,

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.

[Minor] Can we just send enricherConnectionDetailsMap similar to dest filter ? We'll be iterating on connectionDetailsMap and it could have more keys ?

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.

Do you mean using the existing connectionDetailsMap instead of creating a new enricherConnectionDetailsMap?

@itsmihir
itsmihir enabled auto-merge (squash) June 11, 2025 12:44
@itsmihir
itsmihir merged commit 94f40c8 into master Jun 12, 2025
@itsmihir
itsmihir deleted the feat.capture-bot-metric branch June 12, 2025 07:17
This was referenced Jun 16, 2025
itsmihir pushed a commit that referenced this pull request Jun 16, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.52.0-rc.1](v1.51.0...v1.52.0-rc.1)
(2025-06-16)


### Features

* capture bot metrics post deduplication
([#5956](#5956))
([94f40c8](94f40c8))
* detect and handle memory-fenced responses in rudder-server
([#5935](#5935))
([af45808](af45808))
* migrate cloud destinations to v2 sdk
([#5916](#5916))
([93d64f5](93d64f5))
* shutdown server on non-reloadable config change
([#5941](#5941))
([985d3f9](985d3f9))


### Bug Fixes

* duplicates in snowpipe streaming due to stale channel cache
([#5957](#5957))
([4badd49](4badd49))
* gcs file deletion timing out
([#5951](#5951))
([e4abe53](e4abe53))
* update and extend async event delivery time metrics tests for
JobParameters logic
([#5975](#5975))
([01483d5](01483d5))
* warehouse transformations deep copying arguments
([#5979](#5979))
([28d15ac](28d15ac))


### Miscellaneous

* add conversionTime iso 8601 validation for bingads oc
([#5858](#5858))
([3e0dc6f](3e0dc6f))
* create new backoff on every reporting request
([#5993](#5993))
([7e3715a](7e3715a))
* **deps:** bump the go-deps group across 1 directory with 21 updates
([#5983](#5983))
([aa3ee66](aa3ee66))
* remove golang.org/x/crypto v0.32.0
([#5986](#5986))
([6fbb5a3](6fbb5a3))
* sync release v1.51.0 to main branch
([#5971](#5971))
([b9b1a21](b9b1a21))

---
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 Jun 17, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.52.0](v1.51.0...v1.52.0)
(2025-06-16)


### Features

* capture bot metrics post deduplication
([#5956](#5956))
([94f40c8](94f40c8))
* detect and handle memory-fenced responses in rudder-server
([#5935](#5935))
([af45808](af45808))
* migrate cloud destinations to v2 sdk
([#5916](#5916))
([93d64f5](93d64f5))
* shutdown server on non-reloadable config change
([#5941](#5941))
([985d3f9](985d3f9))


### Bug Fixes

* duplicates in snowpipe streaming due to stale channel cache
([#5957](#5957))
([4badd49](4badd49))
* gcs file deletion timing out
([#5951](#5951))
([e4abe53](e4abe53))
* update and extend async event delivery time metrics tests for
JobParameters logic
([#5975](#5975))
([01483d5](01483d5))
* warehouse transformations deep copying arguments
([#5979](#5979))
([28d15ac](28d15ac))


### Miscellaneous

* add conversionTime iso 8601 validation for bingads oc
([#5858](#5858))
([3e0dc6f](3e0dc6f))
* create new backoff on every reporting request
([#5993](#5993))
([7e3715a](7e3715a))
* **deps:** bump the go-deps group across 1 directory with 21 updates
([#5983](#5983))
([aa3ee66](aa3ee66))
* remove golang.org/x/crypto v0.32.0
([#5986](#5986))
([6fbb5a3](6fbb5a3))
* sync release v1.51.0 to main branch
([#5971](#5971))
([b9b1a21](b9b1a21))

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