Skip to content

chore: add sourceDef field to stats and related structures for enhanced observability - #5660

Merged
mihir20 merged 6 commits into
masterfrom
mihir/pipe-1969
Apr 10, 2025
Merged

mihir20 merged 6 commits into
masterfrom
mihir/pipe-1969

Conversation

@mihir20

@mihir20 mihir20 commented Mar 27, 2025

Copy link
Copy Markdown
Contributor

This pull request enhances the Gateway test cases by adding the SourceDefName attribute to various request contexts. The changes improve the clarity and completeness of the test data being used, ensuring that the tests accurately reflect the expected structure of the requests.

Changes Made:

  • Added SourceDefName to the rCtxEnabled structure in multiple test cases.
  • Updated the tags in the requests to include sourceDef, which is now populated with SourceDefName where applicable.

Impact:

These modifications help in validating the behavior of the Gateway under different conditions by ensuring that all relevant data fields are included in the tests. This will aid in identifying any issues related to the sourceDef in future development.

Affected Files:

  • gateway/gateway_test.go

@mihir20
mihir20 requested a review from Copilot March 27, 2025 13:45

Copilot AI 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.

Pull Request Overview

This pull request enhances the test coverage for the Gateway by adding the SourceDefName attribute across several request contexts, ensuring that the tests reflect a more complete data structure.

  • Added a new SourceDef field to the SourceStat type and applied a lower-case conversion before reporting.
  • Updated functions in observability, HTTP auth, and internal batch payload handling to incorporate the SourceDef from the request context.
  • Modified multiple test cases in gateway_test.go and handle_http_auth_test.go to include sourceDef tags and assertions.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
gateway/internal/stats/stats.go Introduced SourceDef field in SourceStat and converted its value to lower-case for stat reporting.
gateway/handle_observability.go Populated SourceDef from the request context (arctx.SourceDefName) in NewSourceStat.
gateway/handle_http_auth_test.go Updated test data to include the sourceDef tag in request assertions.
gateway/handle_http_auth.go Added SourceDef inclusion in failure stats and a debug print statement in writeKeyAuth.
gateway/handle.go Set the SourceDef in SourceStat from the source configuration while extracting internal batch payload jobs.
gateway/gateway_test.go Extended various test cases to include sourceDef in expected tag maps.
Comments suppressed due to low confidence (1)

gateway/gateway_test.go:313

  • [nitpick] Ensure that the value for 'sourceDef' in test assertions matches the expected lower-case conversion applied in the reporting function. If rCtxEnabled.SourceDefName is not already lower-case, it might lead to assertion mismatches.
"sourceDef":   rCtxEnabled.SourceDefName,

Comment thread gateway/handle_http_auth.go Resolved
@mihir20 mihir20 changed the title Add SourceDefName to Gateway Test Cases chore: add sourceDef field to stats and related structures for enhanced observability Mar 27, 2025
@mihir20
mihir20 requested a review from Copilot March 27, 2025 13:48

Copilot AI 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.

Pull Request Overview

This PR enhances observability by adding a new source definition field to statistics and updating related test cases and handlers. Key changes include:

  • Adding a new SourceDef field (with lower-case normalization) in stats reporting.
  • Propagating the source definition from the AuthRequestContext to various handlers.
  • Updating test cases to verify the inclusion of the new sourceDef tag.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gateway/internal/stats/stats.go Introduces the SourceDef field and applies lower-case conversion.
gateway/handle_observability.go Maps the SourceDef field from AuthRequestContext.
gateway/handle_http_auth_test.go Updates expected tags in HTTP auth tests with sourceDef values.
gateway/handle_http_auth.go Propagates sourceDef from AuthRequestContext in failure handling.
gateway/handle.go Extracts and assigns the SourceDef value via the source config.
gateway/gateway_test.go Extends test cases to include sourceDef in various request scenarios.
Comments suppressed due to low confidence (2)

gateway/internal/stats/stats.go:110

  • [nitpick] Review whether the unconditional use of strings.ToLower on ss.SourceDef is intended, as it may lead to discrepancies if source definitions are meant to be case-sensitive.
        "sourceDef":   strings.ToLower(ss.SourceDef),

gateway/handle.go:855

  • [nitpick] Consider aligning the naming between 'SourceDef' in stats and 'SourceDefName' in the AuthRequestContext for better clarity and consistency across the codebase.
        stat.SourceDef = sourceConfig.SourceDefinition.Name

@mihir20
mihir20 marked this pull request as ready for review March 27, 2025 13:52
@mihir20
mihir20 requested a review from ktgowtham March 28, 2025 06:05
@codecov

codecov Bot commented Mar 28, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.96%. Comparing base (15ccaac) to head (69ff68b).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5660      +/-   ##
==========================================
- Coverage   77.01%   76.96%   -0.05%     
==========================================
  Files         487      487              
  Lines       66186    66183       -3     
==========================================
- Hits        50972    50940      -32     
- Misses      12451    12472      +21     
- Partials     2763     2771       +8     

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

@mihir20
mihir20 force-pushed the mihir/pipe-1969 branch 2 times, most recently from 11623bb to 7bc7612 Compare April 2, 2025 07:59
Comment thread gateway/internal/stats/stats.go Outdated

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.

Why do we need sourceDefName to be part of stats tags?

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.

Comment thread gateway/handle.go Resolved
@mihir20
mihir20 requested review from atzoum and ktgowtham April 9, 2025 09:47
mihir20 added 5 commits April 9, 2025 15:22
Signed-off-by: mihir <[email protected]>
…entralize source info retrieval

- Modify `newSourceStatTagsWithReason` to accept message properties directly instead of backendconfig.SourceT
- Add `getSourceDefinitionFromSourceID` and `getSourceNameFromSourceID` helper methods
- Update suppressed events handling to use message properties for stats tagging
- Decouple stats collection from backendconfig source structure by using stream.MessageProperties
- Improve traceability by passing explicit source attributes through processing chain
…ndancy

Replace multiple source config lookup functions with single method getSourceConfigFromSourceID. Combine writeKey, sourceDefName, and sourceName retrieval with a single map access and lock acquisition, improving efficiency. Update error message to reflect broader scope of retrieved data. Simplify user suppression logic by removing unnecessary sourceName lookup.
@mihir20
mihir20 merged commit 632bfca into master Apr 10, 2025
@mihir20
mihir20 deleted the mihir/pipe-1969 branch April 10, 2025 15:40
Sidddddarth pushed a commit that referenced this pull request Apr 14, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.47.0-rc.1](v1.46.0...v1.47.0-rc.1)
(2025-04-14)


### Features

* add a common package for validation
([#5579](#5579))
([f2cee9d](f2cee9d))
* add support for table size metadata in warehouse /v1/process API
([#5705](#5705))
([cbebd23](cbebd23))
* add tracer support to partition and pipeline workers
([#5668](#5668))
([a38b4f5](a38b4f5))
* add upload_id column in wh_load_files table
([#5682](#5682))
([9def123](9def123))
* embedded google pubsub transformer
([#5525](#5525))
([dcdb681](dcdb681))
* embedded kafka transformer
([#5575](#5575))
([224228b](224228b))
* **jobsdb:** introduce jobMinRowsLeftMigrateThres
([#5704](#5704))
([b1f4ce0](b1f4ce0))
* **processor:** concurrent store steps
([#5687](#5687))
([2435cba](2435cba))
* support compacted destination transformation payloads
([#5667](#5667))
([15ccaac](15ccaac))


### Bug Fixes

* handle consent management filtering per connection
([#5718](#5718))
([69f1baf](69f1baf))
* handling isBlank for nested and empty arrays
([#5714](#5714))
([69f1baf](69f1baf))
* kafka message batching applies to Confluent Cloud and Azure Event Hub
([#5699](#5699))
([7d8cdb9](7d8cdb9))
* **router:** applying excessive read pressure to the database when jobs
are being throttled
([#5685](#5685))
([69f1baf](69f1baf))
* **router:** applying excessive read pressure to the database when jobs
are being throttled
([#5685](#5685))
([0b83028](0b83028))
* **router:** applying excessive read pressure to the database when jobs
are being throttled
([#5685](#5685))
([f0e8b75](f0e8b75))
* snowflake fetch schema privileges
([#5692](#5692))
([69f1baf](69f1baf))
* snowflake fetch schema privileges
([#5692](#5692))
([0b83028](0b83028))
* warehouse transformations comparisions
([#5694](#5694))
([69f1baf](69f1baf))
* warehouse transformations comparisions
([#5694](#5694))
([0b83028](0b83028))
* warehouse transformations ordering for comparison
([#5670](#5670))
([28ba26e](28ba26e))
* warehouse transformations ordering while processing properties
([#5713](#5713))
([69f1baf](69f1baf))
* warehouse transformations valid timestamp formats and log file path
([#5707](#5707))
([69f1baf](69f1baf))


### Miscellaneous

* add sourceDef field to stats and related structures for enhanced
observability
([#5660](#5660))
([632bfca](632bfca))
* avoid using reflections for warehouse transformations
([#5673](#5673))
([3290794](3290794))
* clean up tests because transformer defaults to v2
([#5712](#5712))
([e9b96cf](e9b96cf))
* datetime detection
([#5675](#5675))
([1c53807](1c53807))
* default webhook contract version to v2
([#5659](#5659))
([7dbf5d8](7dbf5d8))
* **deps:** bump beatlabs/delete-old-branches-action from 0.0.10 to
0.0.11
([#5620](#5620))
([451c593](451c593))
* **deps:** bump google.golang.org/api from 0.227.0 to 0.228.0 in the
frequent group
([#5708](#5708))
([cbce33a](cbce33a))
* **deps:** bump the frequent group across 1 directory with 3 updates
([#5702](#5702))
([00a1bc5](00a1bc5))
* **deps:** bump the go-deps group across 1 directory with 12 updates
([#5698](#5698))
([4c3e4ff](4c3e4ff))
* **deps:** bump the go-deps group with 2 updates
([#5701](#5701))
([27c71e6](27c71e6))
* **deps:** bump the go-deps group with 2 updates
([#5709](#5709))
([1335fa6](1335fa6))
* **deps:** bump the go-deps group with 2 updates
([#5719](#5719))
([d3ab3e6](d3ab3e6))
* remove explicit schema synchronization in upload job
([#5672](#5672))
([462db8a](462db8a))
* remove unused schema v1 code
([#5661](#5661))
([3290794](3290794))
* snowflake integrations tests to use keypair instead of password
([#5684](#5684))
([3ed7a11](3ed7a11))

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


##
[1.47.0-rc.2](v1.46.0...v1.47.0-rc.2)
(2025-04-14)


### Features

* add a common package for validation
([#5579](#5579))
([f2cee9d](f2cee9d))
* add support for table size metadata in warehouse /v1/process API
([#5705](#5705))
([cbebd23](cbebd23))
* add tracer support to partition and pipeline workers
([#5668](#5668))
([a38b4f5](a38b4f5))
* add upload_id column in wh_load_files table
([#5682](#5682))
([9def123](9def123))
* embedded google pubsub transformer
([#5525](#5525))
([dcdb681](dcdb681))
* embedded kafka transformer
([#5575](#5575))
([224228b](224228b))
* **jobsdb:** introduce jobMinRowsLeftMigrateThres
([#5704](#5704))
([b1f4ce0](b1f4ce0))
* **processor:** concurrent store steps
([#5687](#5687))
([2435cba](2435cba))
* support compacted destination transformation payloads
([#5667](#5667))
([15ccaac](15ccaac))


### Bug Fixes

* handle consent management filtering per connection
([#5718](#5718))
([69f1baf](69f1baf))
* handling isBlank for nested and empty arrays
([#5714](#5714))
([69f1baf](69f1baf))
* kafka message batching applies to Confluent Cloud and Azure Event Hub
([#5699](#5699))
([7d8cdb9](7d8cdb9))
* **router:** applying excessive read pressure to the database when jobs
are being throttled
([#5685](#5685))
([f0e8b75](f0e8b75))
* snowflake fetch schema privileges
([#5692](#5692))
([0b83028](0b83028))
* unmarshalling error for staging files without bytes per table
([#5725](#5725))
([8c35d0a](8c35d0a))
* warehouse transformations comparisions
([#5694](#5694))
([0b83028](0b83028))
* warehouse transformations ordering for comparison
([#5670](#5670))
([28ba26e](28ba26e))
* warehouse transformations ordering while processing properties
([#5713](#5713))
([69f1baf](69f1baf))
* warehouse transformations valid timestamp formats and log file path
([#5707](#5707))
([69f1baf](69f1baf))


### Miscellaneous

* add sourceDef field to stats and related structures for enhanced
observability
([#5660](#5660))
([632bfca](632bfca))
* avoid using reflections for warehouse transformations
([#5673](#5673))
([3290794](3290794))
* clean up tests because transformer defaults to v2
([#5712](#5712))
([e9b96cf](e9b96cf))
* datetime detection
([#5675](#5675))
([1c53807](1c53807))
* default webhook contract version to v2
([#5659](#5659))
([7dbf5d8](7dbf5d8))
* **deps:** bump beatlabs/delete-old-branches-action from 0.0.10 to
0.0.11
([#5620](#5620))
([451c593](451c593))
* **deps:** bump google.golang.org/api from 0.227.0 to 0.228.0 in the
frequent group
([#5708](#5708))
([cbce33a](cbce33a))
* **deps:** bump the frequent group across 1 directory with 3 updates
([#5702](#5702))
([00a1bc5](00a1bc5))
* **deps:** bump the go-deps group across 1 directory with 12 updates
([#5698](#5698))
([4c3e4ff](4c3e4ff))
* **deps:** bump the go-deps group with 2 updates
([#5701](#5701))
([27c71e6](27c71e6))
* **deps:** bump the go-deps group with 2 updates
([#5709](#5709))
([1335fa6](1335fa6))
* **deps:** bump the go-deps group with 2 updates
([#5719](#5719))
([d3ab3e6](d3ab3e6))
* remove explicit schema synchronization in upload job
([#5672](#5672))
([462db8a](462db8a))
* remove unused schema v1 code
([#5661](#5661))
([3290794](3290794))
* snowflake integrations tests to use keypair instead of password
([#5684](#5684))
([3ed7a11](3ed7a11))

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


##
[1.47.0](v1.46.0...v1.47.0)
(2025-04-14)


### Features

* add a common package for validation
([#5579](#5579))
([f2cee9d](f2cee9d))
* add support for table size metadata in warehouse /v1/process API
([#5705](#5705))
([cbebd23](cbebd23))
* add tracer support to partition and pipeline workers
([#5668](#5668))
([a38b4f5](a38b4f5))
* add upload_id column in wh_load_files table
([#5682](#5682))
([9def123](9def123))
* embedded google pubsub transformer
([#5525](#5525))
([dcdb681](dcdb681))
* embedded kafka transformer
([#5575](#5575))
([224228b](224228b))
* **jobsdb:** introduce jobMinRowsLeftMigrateThres
([#5704](#5704))
([b1f4ce0](b1f4ce0))
* **processor:** concurrent store steps
([#5687](#5687))
([2435cba](2435cba))
* support compacted destination transformation payloads
([#5667](#5667))
([15ccaac](15ccaac))


### Bug Fixes

* handle consent management filtering per connection
([#5718](#5718))
([69f1baf](69f1baf))
* handling isBlank for nested and empty arrays
([#5714](#5714))
([69f1baf](69f1baf))
* kafka message batching applies to Confluent Cloud and Azure Event Hub
([#5699](#5699))
([7d8cdb9](7d8cdb9))
* **router:** applying excessive read pressure to the database when jobs
are being throttled
([#5685](#5685))
([f0e8b75](f0e8b75))
* snowflake fetch schema privileges
([#5692](#5692))
([0b83028](0b83028))
* unmarshalling error for staging files without bytes per table
([#5725](#5725))
([8c35d0a](8c35d0a))
* warehouse transformations comparisions
([#5694](#5694))
([0b83028](0b83028))
* warehouse transformations concurrent writes
([#5724](#5724))
([68e6309](68e6309))
* warehouse transformations ordering for comparison
([#5670](#5670))
([28ba26e](28ba26e))
* warehouse transformations ordering while processing properties
([#5713](#5713))
([69f1baf](69f1baf))
* warehouse transformations valid timestamp formats and log file path
([#5707](#5707))
([69f1baf](69f1baf))


### Miscellaneous

* add sourceDef field to stats and related structures for enhanced
observability
([#5660](#5660))
([632bfca](632bfca))
* avoid using reflections for warehouse transformations
([#5673](#5673))
([3290794](3290794))
* clean up tests because transformer defaults to v2
([#5712](#5712))
([e9b96cf](e9b96cf))
* datetime detection
([#5675](#5675))
([1c53807](1c53807))
* default webhook contract version to v2
([#5659](#5659))
([7dbf5d8](7dbf5d8))
* **deps:** bump beatlabs/delete-old-branches-action from 0.0.10 to
0.0.11
([#5620](#5620))
([451c593](451c593))
* **deps:** bump google.golang.org/api from 0.227.0 to 0.228.0 in the
frequent group
([#5708](#5708))
([cbce33a](cbce33a))
* **deps:** bump the frequent group across 1 directory with 3 updates
([#5702](#5702))
([00a1bc5](00a1bc5))
* **deps:** bump the go-deps group across 1 directory with 12 updates
([#5698](#5698))
([4c3e4ff](4c3e4ff))
* **deps:** bump the go-deps group with 2 updates
([#5701](#5701))
([27c71e6](27c71e6))
* **deps:** bump the go-deps group with 2 updates
([#5709](#5709))
([1335fa6](1335fa6))
* **deps:** bump the go-deps group with 2 updates
([#5719](#5719))
([d3ab3e6](d3ab3e6))
* remove explicit schema synchronization in upload job
([#5672](#5672))
([462db8a](462db8a))
* remove unused schema v1 code
([#5661](#5661))
([3290794](3290794))
* snowflake integrations tests to use keypair instead of password
([#5684](#5684))
([3ed7a11](3ed7a11))

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