Skip to content

feat: dedicated reporting client with cost attribution metrics - #5529

Closed
lvrach wants to merge 3 commits into
masterfrom
feat.reporting-metrics
Closed

lvrach wants to merge 3 commits into
masterfrom
feat.reporting-metrics

Conversation

@lvrach

@lvrach lvrach commented Feb 19, 2025 •

Copy link
Copy Markdown
Member

Description

While working on the reporting code base to add metrics for cost attribution.

Linear Ticket

< Replace with Linear Link ( create or search linear ticket) or >

Security

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

@lvrach lvrach changed the title feat: create dedicated reporting client feat: dedicated reporting client with cost attribution metrics Feb 19, 2025
@codecov

codecov Bot commented Feb 19, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 69.18239% with 49 lines in your changes missing coverage. Please review.

Project coverage is 75.42%. Comparing base (f3e5d1a) to head (13ad709).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
enterprise/reporting/client.go 66.43% 35 Missing and 13 partials ⚠️
enterprise/reporting/error_reporting.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5529      +/-   ##
==========================================
+ Coverage   75.09%   75.42%   +0.32%     
==========================================
  Files         467      474       +7     
  Lines       64053    64904     +851     
==========================================
+ Hits        48101    48954     +853     
+ Misses      13283    13247      -36     
- Partials     2669     2703      +34     

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

@github-actions

Copy link
Copy Markdown
Contributor

This PR is considered to be stale. It has been open 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR.

@github-actions github-actions Bot added the Stale label Mar 13, 2025
@github-actions github-actions Bot closed this Mar 21, 2025
lvrach added a commit that referenced this pull request Apr 15, 2025
# Description

## Motivation

To introduce a cost attribution metric for all reporting services. I've
noticed coupling and discrepancies between different client
implementations, making it hard to test the changes and requiring
redundant effort.

First, I attempted a more
[aggressive](#5529)
refactor effort.

However, after discussing this with the PipeOps team, we decided to take
a more cynical approach.

## Plan 

* Introduce a common client for all communication with the reporting
service
* Support switching to the new common client via a single feature flag
* Intention to remove old client/send method in the next release.

It was also decided
* To break the backward compatibility with metrics exposed by old
clients. This might break some dashboards, but no alert should be
impacted.


## Changes


### Metric names
New metrics:

```go
const (
	StatRequestTotalBytes     = "reporting_client_http_request_total_bytes"
	StatTotalDurationsSeconds = "reporting_client_http_total_durations_seconds"
	StatRequestLatency        = "reporting_client_http_request_latency"
	StatHttpRequest           = "reporting_client_http_request"
)
```

Deprecated metrics -- will no longer work after switching to the common
client:

```go
	f.reqLatency = f.stats.NewTaggedStat("reporting_flusher_http_request_duration_seconds", stats.TimerType, tags)
	f.reqCount = f.stats.NewTaggedStat("reporting_flusher_http_requests_total", stats.CountType, tags)
	f.sentBytes = f.stats.NewTaggedStat("reporting_flusher_sent_bytes", stats.HistogramType, tags)
	
        edr.stats.NewTaggedStat("error_detail_reporting_http_request", stats.CountType, httpStatTags).Increment()
	edr.edReportingRequestLatency = edr.stats.NewTaggedStat("error_detail_reporting_request_latency", stats.TimerType, tags)
```
### Metric labels 

Changes:

* `workspaceID` -- REMOVED will no longer be captured by the client, as
it is not relevant when multiple workspaces are batch to a single call
* `clientName` -- RENAMED --> `module`
*  `endpoint` --> ADDED: reporting URL 
* `path` --> ADDED: reporting path/service

### `region` query param 

Region query parameter, used only by some reporting clients **has been
removed**.

Based on team feedback this query param was used temporary for multi
region transition and is no longer needed.

### `REPORTING_URL` env var 

REPORTING_URL now always defaults to
`"https://reporting.dev.rudderlabs.com"`

Some of the existing clients defaulted to
`https://reporting.rudderstack.com/`


## To Be Discussed

* Should we use a default value for `REPORTING_URL`, would we rather
fail if `REPORTING_URL` is not configured ? It could be a privacy risk
for EU customers if reporting us endpoint is configured accidentally.
* Should we introduce `.Ping()` method and corresponding endpoint ? 


## Next steps

1. Rollout `useCommonClient` flag in production
2. Update Grafana dashboards as need
3. Remove all deprecated code (most of it is marked with commends`
4. Start the work for unifying reporting logic

## Linear Ticket

Resolves PRI-168


https://linear.app/rudderstack/issue/PRI-168/introduce-reporting-client-metrics-in-rudder-server-for-cost

## Security

- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
@github-actions
github-actions Bot deleted the feat.reporting-metrics branch May 23, 2025 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant