Skip to content

feat(router): add request latency and count metrics for router deliveries - #6288

Merged
koladilip merged 6 commits into
masterfrom
feature/int-3991-endpoint-metrics-for-router-deliveries
Sep 3, 2025
Merged

koladilip merged 6 commits into
masterfrom
feature/int-3991-endpoint-metrics-for-router-deliveries

Conversation

@koladilip

Copy link
Copy Markdown
Contributor

Description

This PR implements the transformer_outgoing_request_latency metric in the router to match transformer's metric structure and improve observability of HTTP requests to destination endpoints.

Changes Made

  • Added recordTransformerOutgoingRequestLatency method to worker struct
  • Records metric only when EndpointPath is present in PostParametersT
  • Includes comprehensive labels: feature, destType, endpointPath, requestMethod, module, workspaceId, destinationId, sourceId
  • Added comprehensive unit tests covering various scenarios including edge cases
  • Matches transformer's metric structure for consistent observability

Implementation Details

  • Metric Name: transformer_outgoing_request_latency
  • Type: Histogram (TimerType in Go stats)
  • Location: router/worker.go around line 520 for non-proxy requests
  • Condition: Only emits when EndpointPath is not empty
  • Labels: All labels match transformer's label set exactly

Testing

  • Added comprehensive unit tests with 3 test cases:
    1. Complete data with endpoint path (should emit)
    2. Empty endpoint path (should not emit)
    3. Empty job metadata array with endpoint path (should emit)
  • All tests pass successfully
  • No regression in existing router functionality

Linear Ticket

https://linear.app/rudderstack/issue/INT-3991/endpoint-metrics-for-router-deliveries

Security

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

@koladilip
koladilip force-pushed the feature/int-3991-endpoint-metrics-for-router-deliveries branch from e2dc344 to de2e7d3 Compare September 1, 2025 08:34
Comment thread router/worker.go Resolved
@koladilip koladilip changed the title feat(router): add transformer_outgoing_request_latency metric for router deliveries feat(router): add request latency and count metric for router deliveries Sep 2, 2025
@koladilip koladilip changed the title feat(router): add request latency and count metric for router deliveries feat(router): add request latency and count metrics for router deliveries Sep 2, 2025
@koladilip
koladilip force-pushed the feature/int-3991-endpoint-metrics-for-router-deliveries branch from 9b23c4a to 20fa444 Compare September 2, 2025 07:48
Comment thread router/worker.go Resolved
@koladilip
koladilip force-pushed the feature/int-3991-endpoint-metrics-for-router-deliveries branch from 30e0892 to c55ac9d Compare September 2, 2025 10:19
@koladilip
koladilip requested a review from atzoum September 2, 2025 12:34
@koladilip
koladilip force-pushed the feature/int-3991-endpoint-metrics-for-router-deliveries branch from 4224825 to 91cb740 Compare September 2, 2025 14:19
…ter deliveries

- Add recordTransformerOutgoingRequestLatency method to worker struct
- Record metric only when EndpointPath is present in PostParametersT
- Include labels: feature, destType, endpointPath, requestMethod, module, workspaceId, destinationId, sourceId
- Add comprehensive unit tests covering various scenarios
- Match transformer's metric structure for consistent observability

Resolves INT-3991
- Replace single metric with both transformer_outgoing_request_latency and transformer_outgoing_request_count
- Update labels to match transformer structure: destType, endpointPath, statusCode, requestMethod, module, workspaceId, destinationId
- Remove feature and sourceId labels as per requirements
- Add statusCode from HTTP response
- Update tests to verify both metrics are recorded correctly
- Only emit metrics when EndpointPath is present
…uct keys

- Replace string-based cache keys with deliveryMetricLabel struct
- Use mapstructure tags for automatic label conversion
- Add comprehensive tests for caching behavior and mapstructure functionality
- Improve performance by avoiding stats object recreation
- Maintain backward compatibility while enhancing maintainability
@koladilip
koladilip force-pushed the feature/int-3991-endpoint-metrics-for-router-deliveries branch from 91cb740 to 66dd47b Compare September 2, 2025 14:20
@koladilip
koladilip enabled auto-merge (squash) September 2, 2025 14:44
Comment thread router/worker.go Resolved
Comment thread router/worker.go Resolved
@koladilip
koladilip requested a review from atzoum September 3, 2025 04:56
@koladilip
koladilip force-pushed the feature/int-3991-endpoint-metrics-for-router-deliveries branch from 9ee6c61 to 8a99477 Compare September 3, 2025 05:05
Comment thread router/worker_test.go Resolved
Comment thread router/worker_test.go Resolved
Comment thread router/worker_test.go Resolved
Comment thread router/worker_test.go Resolved
@koladilip
koladilip requested a review from atzoum September 3, 2025 09:30
@koladilip
koladilip force-pushed the feature/int-3991-endpoint-metrics-for-router-deliveries branch from db6815f to ab35886 Compare September 3, 2025 09:45
@koladilip
koladilip merged commit c8dd8ef into master Sep 3, 2025
@koladilip
koladilip deleted the feature/int-3991-endpoint-metrics-for-router-deliveries branch September 3, 2025 10:12
This was referenced Sep 15, 2025
satishrudderstack pushed a commit that referenced this pull request Sep 15, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.59.0-rc.1](v1.58.0...v1.59.0-rc.1)
(2025-09-15)


### Features

* **router:** add request latency and count metrics for router
deliveries
([#6288](#6288))
([c8dd8ef](c8dd8ef))


### Bug Fixes

* avoid running migrations for notifier from slaves
([#6303](#6303))
([761eb46](761eb46))
* **batchrouter:** support configurable column ordering in CSVs in sftp
([#6342](#6342))
([652215b](652215b))
* populate table level schemas createdAt updatedAt
([#6344](#6344))
([a76a509](a76a509))
* remove unwanted table level schemas
([#6296](#6296))
([761eb46](761eb46))
* **router:** kinesis rate exceeded errors are being aborted with http
400 ([#6329](#6329))
([f739d7f](f739d7f))
* update ID regex to include underscores in error cleanup
([#6315](#6315))
([bc1a751](bc1a751))


### Miscellaneous

* add logs for events coming with an incorrect source and sourceRunId
([#6309](#6309))
([17afa60](17afa60))
* add readme for OAuth module
([#6335](#6335))
([3c9f251](3c9f251))
* bump go-kit
([#6321](#6321))
([87499e0](87499e0))
* bump mvdan.cc/gofumpt to v0.9.1
([#6328](#6328))
([cf9f653](cf9f653))
* capture stats for failed transformer client requests
([#6300](#6300))
([e10d5c1](e10d5c1))
* clean up legacy MTU logic
([#6314](#6314))
([a2e753d](a2e753d))
* clean up logs to trace double-encoded HLL value issue
([#6310](#6310))
([c707aea](c707aea))
* drop unused services/oauth v1 and minor v2 tidy-ups
([#6275](#6275))
([c1b84c1](c1b84c1))
* improve googlesheets oauth flow and error handling
([#6340](#6340))
([738d420](738d420))
* optimize dtransform payloads and have compaction always enabled
([#6331](#6331))
([63af856](63af856))
* remove proc_error jobsdb
([#6287](#6287))
([5b92665](5b92665))
* renaming mirroring modes
([#6325](#6325))
([84687fb](84687fb))
* **router:** ignore throttling costs in pickup throttler
([#6316](#6316))
([af85b92](af85b92))
* sync release v1.58.0 to main branch
([#6294](#6294))
([565630e](565630e))
* unify adaptive and static throttling configuration
([#6327](#6327))
([077b0fb](077b0fb))
* update rudderlabs/build-scan-push-action to 1.7.0
([#6320](#6320))
([edb02d3](edb02d3))
* updating keydb client
([#6301](#6301))
([0f9e3ec](0f9e3ec))

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


##
[1.59.0](v1.58.0...v1.59.0)
(2025-09-15)


### Features

* **router:** add request latency and count metrics for router
deliveries
([#6288](#6288))
([c8dd8ef](c8dd8ef))


### Bug Fixes

* avoid running migrations for notifier from slaves
([#6303](#6303))
([761eb46](761eb46))
* **batchrouter:** support configurable column ordering in CSVs in sftp
([#6342](#6342))
([652215b](652215b))
* populate table level schemas createdAt updatedAt
([#6344](#6344))
([a76a509](a76a509))
* remove unwanted table level schemas
([#6296](#6296))
([761eb46](761eb46))
* **router:** kinesis rate exceeded errors are being aborted with http
400 ([#6329](#6329))
([f739d7f](f739d7f))
* update ID regex to include underscores in error cleanup
([#6315](#6315))
([bc1a751](bc1a751))


### Miscellaneous

* add logs for events coming with an incorrect source and sourceRunId
([#6309](#6309))
([17afa60](17afa60))
* add readme for OAuth module
([#6335](#6335))
([3c9f251](3c9f251))
* bump go-kit
([#6321](#6321))
([87499e0](87499e0))
* bump mvdan.cc/gofumpt to v0.9.1
([#6328](#6328))
([cf9f653](cf9f653))
* capture stats for failed transformer client requests
([#6300](#6300))
([e10d5c1](e10d5c1))
* clean up legacy MTU logic
([#6314](#6314))
([a2e753d](a2e753d))
* clean up logs to trace double-encoded HLL value issue
([#6310](#6310))
([c707aea](c707aea))
* drop unused services/oauth v1 and minor v2 tidy-ups
([#6275](#6275))
([c1b84c1](c1b84c1))
* improve googlesheets oauth flow and error handling
([#6340](#6340))
([738d420](738d420))
* optimize dtransform payloads and have compaction always enabled
([#6331](#6331))
([63af856](63af856))
* remove proc_error jobsdb
([#6287](#6287))
([5b92665](5b92665))
* renaming mirroring modes
([#6325](#6325))
([84687fb](84687fb))
* **router:** ignore throttling costs in pickup throttler
([#6316](#6316))
([af85b92](af85b92))
* sync release v1.58.0 to main branch
([#6294](#6294))
([565630e](565630e))
* unify adaptive and static throttling configuration
([#6327](#6327))
([077b0fb](077b0fb))
* update rudderlabs/build-scan-push-action to 1.7.0
([#6320](#6320))
([edb02d3](edb02d3))
* updating keydb client
([#6301](#6301))
([0f9e3ec](0f9e3ec))

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

3 participants