-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exporter/loadbalacing] Refactor how metrics are split and then re-jo…
…ined after load-balacing (#33293) **Description:** The previous code splits an incoming `pmetric.Metrics` into individual `pmetric.Metrics` instances, at the granularity of `pmetric.Metric`. Then afterwards, it used the various routingID functions to create a map of booleans, in order to define how the metrics should be routed. Finally, it merged the metrics by routing key, and exported them by concatenating them all together. While this worked, it's somewhat hard to follow, and inefficient for most of the routingIDs. In a future PR, we'd like to add a new routingID, which would require splitting at the datapoint level. This would add a ton of extra work for the other routingIDs, which don't care about specific datapoints. Therefore, the new code has dedicated splitting functions for each routingID. These functions directly return a `map[string]pmetric.Metrics` instance. IE, a map of routing keys to its metrics. These functions can be unit tested directly, and makes the logic in `ConsumeMetrics()` very easy to follow. Lastly, when combining metrics for routing, the new code utilizes the `MergeMetrics()` helper function from `internal/exp/metrics`. This merges the metrics and removes duplicate ResourceMetrics / ScopeMetrics instances. Which saves compute and bandwidth for serialization downstream. **Link to tracking Issue:** 32513 **Testing:** I created a full suite of tests for each routingID enum. For both single endpoint, as well an multi-endpoint loadbalancing **Documentation:** The code is documented in comments. I added a changelog entry to explain changes for users --------- Co-authored-by: Pablo Baeyens <[email protected]>
- Loading branch information
1 parent
2fd817f
commit d6eaca8
Showing
34 changed files
with
2,185 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: loadbalancerexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Refactors how the load balancing exporter splits metrics | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [32513] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: All splitting is *behaviorally*, the same. However, the `resource` routingID now uses the `internal/exp/metrics/identity` package to generate the load balancing key, instead of bespoke code. This means that when upgrading to this version your routes for specific metric groupings could change. However, this will be stable and all future metrics will follow the new routing | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [user] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.